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 2 years 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:

01local RS = game:GetService("ReplicatedStorage")
02 
03local enemiesFolder = RS.Enemies
04local enemySpawn = workspace.EnemySpawns:GetChildren()
05local moveToParts = workspace.MoveToParts:GetChildren()
06 
07local randomSpawn = enemySpawn[math.random(1, #enemySpawn)]
08local randomMoveToPart = moveToParts[math.random(1, #moveToParts)]
09 
10local function Round1()
11 
12    local Round1Enemy = enemiesFolder.Enemy1:Clone()
13    Round1Enemy.Parent = workspace.Enemies
14    Round1Enemy.HumanoidRootPart.Position = randomSpawn.Position
15    Round1Enemy.Humanoid:MoveTo(randomMoveToPart.Position)
View all 21 lines...

Thanks for the help! -KoalaKrush

1 answer

Log in to vote
0
Answered by 2 years 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