So basically in the script listed below the part moves forward, (its a mesh of a car) then moves backwards to repeat itself. how do I make the process of it Cframing backwards faster?
while true do wait() for i= 1, 300 do script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,0,-2) wait() end for i= 1, 300 do script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,0,2) wait() end end
You can simply use https://developer.roblox.com/api-reference/function/TweenService/Create for smooth and timed results. TweenInfo.new also has a Reverses argument that does exactly what you want.
To do it in your manner, although I highly don't suggest it - you can just double the CFrame it's incrementing the part from script.Parent.CFrame
. You will also need to compensate for the loop so it doesn't overshoot.
while true do wait() for i= 1, 300 do script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,0,-2) wait() end for i= 1, 150 do script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,0,4) wait() end end