Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to move a models position slowly?

Hi im really confused on moving a models position to a vector3 value. This is what i attempted.

wait(3)
while true do
	game.Workspace.Ship.sail.Position = game.Workspace.Ship.sail.Position + Vector3.new(0,0,1)
	game.Workspace.Ship.untitled.Position = game.Workspace.Ship.untitled.Position + Vector3.new(0,0,1)
	
	if game.Workspace.Ship.sail.Position == Vector3.new(3.26, 0.5, -177.74)
		game.Workspace.Ship.untitled.Position == Vector3.new(3.26, 0.5, -177.74)
		
	then
		break
	end
		
end

3 answers

If you want something to smoothly transition between states you should use tweenservice in your case you want to smoothly move a Model. but TweenService on model requires some extra things. You have to set a PrimaryPart and weld every other part inside the model to this PrimaryPart (I recommend that you use WeldConstraints) make sure that the welded parts arent anchored and then tween the PrimaryPart like any other Part. Also make sure if you use WeldConstraints that you tween the CFrame property and not the Position Properpty since when u do Position it will not move the whole model but just instead set a new offset for that part

Tween service should be a good idea for you slowly move your model. But if you want to move the WHOLE model, you should use primary parts.

Tween service should be a good idea but I like to use this way (Recommend only a single part, not whole):

----LOCALS---- (DONT MOVE)
local part = script.Parent

----VARIABLES (SETTINGS)----
repeattimes = 10 -- change this to higher if you want to make the part goes longer
changingtimes = 0.5 -- change this if you want to make the part goes faster (dont use 0 it will crash ur game cuz too fast)

----CODE---- (DONT MOVE)
repeat
	part.Position = part.Position + Vector3.new(0,0,1)
	wait(0.5)
	repeattimes = repeattimes - 1
until	repeattimes == 0

2 comments

0

sorry for the bad code and bad grammar and everything bad bad but i hope it helps

0

this would move much less smoother than if you would do it with TweenService I highly recommend you to learn it, you can use it on almost anything and any property

TweenService will probably help you (it can help you move it very smoothly), but the answer to your question is:

-- let's say you have 'model' and 'dest' (the Vector3 you want the model to go to)
model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame() + dest - model:GetPrimaryPartCFrame().Position)

Of course, you need a primary part in the model for this to work.

If you wish to use TweenService with this you can:

  1. Weld everything to the primary part
  2. Tween a Vector3Value and, every frame, update the model's position with the code above
  3. Every frame, use TweenService:GetValue and perform the tween yourself

This discussion is preserved as it was. New answers, comments, and votes are closed.