如何解决NPC被抛出地图或分裂

我刚刚用以下脚本制作了一个在随机位置克隆NPC的脚本,但是NPC不会出现在我在脚本中指定的任何生成位置,只会出现在地图的中心。克隆时它们还会被抛出地图或分裂。我应该使用表来解决吗?如何解决?

local module = {}

wavepause = game.ReplicatedStorage.Values.WavePauseLength.Value
trollanoid = game.ReplicatedStorage.Trollanoid
spawnpoints = workspace.Test1.Spawns:GetChildren()

function trollanoidsummon()
    local chosenspawn = spawnpoints[math.random(#spawnpoints)]
    local clone = trollanoid:Clone()
    clone.Parent = workspace.Zombies
    clone.UpperTorso.Position = chosenspawn.Position
end

module.Wave1 = function()
    wait(20)
    trollanoidsummon()
    wait(1)
    trollanoidsummon()
    wait(1)
    trollanoidsummon()
    wait(1)
    trollanoidsummon()
end

return module
点赞
用户11886689
用户11886689

尝试设置 Trollanoid 的 HumanoidRootPart 的 CFrame

function trollanoidsummon()
    local chosenspawn = spawnpoints[math.random(#spawnpoints)]
    local clone = trollanoid:Clone()
    clone.Parent = workspace.Zombies
    clone.HumanoidRootPart.CFrame= chosenspawn.CFrame
end
2020-12-26 16:45:04