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

How to make a smooth moving part?

Asked by 7 years ago

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

0
Use lerping. H4X0MSYT 536 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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
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 plagueus 44 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

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.

0
and if i want it to loop infinitly? Pizza64X 8 — 7y
0
then do while true do GameBoyOtaku 63 — 7y

Answer this question