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

How do I move a model to a specific position in the game?

Asked by
ExcelUp 24
5 years ago
Edited 5 years ago

I'm wanting to move a model named 'crate' to the position of another part on the map, named 'crateSpawnLocationA'. SetPrimaryPartCFrame() does move the model, but not directly to the position of the part. Can someone please help me?

crate:SetPrimaryPartCFrame(crate:GetPrimaryPartCFrame() * CFrame.new (game:GetService("Workspace").crateSpawnLocationA.Position))
0
remove the crate:GetPrimaryPartCFrame() theCJarmy7 1293 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

Well, it moves cause it works. What you did wrong is actually set the wrong PrimaryPart. You want to make sure the primary part is always the CENTER part. This ensures that the center is moved to that positions and everything else moves along with it.

I suggest you change the Primary Part of the Crate

also, a fixed script if you simply want to move the model to a part

crate:SetPrimaryPartCFrame(CFrame.new(game.Workspace.crateSpawnLocationA.Position))

You don't need the multiplication and also you don't need :GetService on Workspace.

Either do workspace or game.Workspace.

Hopefully after doing all of this helped you solve your problem. If your script doesn't work Comment below your error if you have one or the issue you are having

Best of luck to you Developer!

Ad
Log in to vote
0
Answered by 5 years ago

You could try having the crate move Via; Vector3

game.Workspace.crate.Position = Vector3.new(Position)

If this doesn't work I wish you the best of luck.

0
Or If you want the script in the crate script.Parent.Position = Vector3.new(position) oshawat00 62 — 5y

Answer this question