Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I fix this model positions with a script?

Asked by 1 year ago

When I clone a model and change its position to a part's, the pivot point is at the part but not the model, how do i fix?

Here is my script:

local RS = game:GetService("ReplicatedStorage")

local enemiesFolder = RS.Enemies
local enemySpawn = workspace.EnemySpawns:GetChildren()
local moveToParts = workspace.MoveToParts:GetChildren()

local randomSpawn = enemySpawn[math.random(1, #enemySpawn)]
local randomMoveToPart = moveToParts[math.random(1, #moveToParts)]

local function Round1()

    local Round1Enemy = enemiesFolder.Enemy1:Clone()
    Round1Enemy.Parent = workspace.Enemies
    Round1Enemy.HumanoidRootPart.Position = randomSpawn.Position
    Round1Enemy.Humanoid:MoveTo(randomMoveToPart.Position)

end

while wait(5) do
    Round1()
end

Thanks for the help! -KoalaKrush

1 answer

Log in to vote
0
Answered by 1 year ago

I ensured the model is unanchored and welded With the exception of HumanoidRootPart HumanoidRootPart can remain anchored I needed to use Model:PivotTo()

Ad

Answer this question