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

How to make a smooth moving part?

Hello im a fresh new scripter, i searched on youtube for how to make moving parts. But it's not working. And i want them to move smoothly

1 comment

0

Use lerping.

2 answers

✓ Accepted answer

Like this?

	local Part = (Insert object here) -- For example workspace.Part
	local Vector3Pos = Vector3.new(number,number,number) -- Target
	local Second = 0.5 -- Optional
	local X,Y,Z
	local DX,DY,DZ = (Part.Position.X-Vector3Pos.X),(Part.Position.Y-Vector3Pos.Y),(Part.Position.Z-Vector3Pos.Z)
	for i=1,(Seconds*50) do
		X=Part.Position.X-(DX/50)
		Y=Part.Position.Y-(DY/50)
		Z=Part.Position.Z-(DZ/50)
		Part.Position=Vector3.new(X,Y,Z)
		wait(Seconds/50)
	end

/* edit */ or this?

	local Part = (Insert object here) -- For example workspace.Part
	local Vector3Pos = Vector3.new(number,number,number) -- Target
Part:lerp(Vector3Pos, (insert number here (alpha))) -- Forgot to mention tweening

1 comment

0

there are many ways you could do this, such as repeatedly updating the part's CFrame, however in my opinion one of the most smoothest and efficient ways is using something called Tween. you can find more on it here: http://wiki.roblox.com/index.php?title=API:Class/TweenService

this is simple so lets say you have a part that is 5 studs from the center of the map now you want it to move smoothly without using Vector 3 ig i don't use those here is what you do

local part = script.Parent
for num = 0, 1, 0.1 -- How many times it will loop idk
part.CFrame = part.CFame:lerp(CFrame.new(0,0,0), num)
wait()

the should smoothly move the brick in the center of the map I didn't test it.

2 comments

0

and if i want it to loop infinitly?

0

then do while true do

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