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

Part teleports back instnatly after reaching its goal, I want it to move back smoothly halp?

local Part = workspace.Part
local test = workspace:WaitForChild('test')
while wait(1) do 
for num = 0,1, .01 do
	Part.CFrame = CFrame.new(7.31, 0.5, 33.97):lerp(CFrame.new(57.15, 25.33, 33.97), num) 
	if Part.CFrame == CFrame.new(57.15, 25.33, 33.97) then
		Part.CFrame = CFrame.new(57.15, 25.33, 33.97):lerp(CFrame.new(7.31, 0.5, 33.97, num))
	end
	game:GetService("RunService").RenderStepped:wait()
end
end

That is what i have so far, any advice/halp?

1 comment

0

put wait()'s in between the functions

1 answer

So i want you to create two parts exactly opposite eachother name one pointA name the other pointB and group them then create the part thats going to slide and call it slider then put this script into the slider

local model = script.Parent.Parent
local slider = model.slider
local start = model.pointA
local finish = model.pointB
local bodyPos = slider.BodyPosition
local time = 2 

while true do
	bodyPos.position = start.Position
	wait(time)
	bodyPos.position = finish.Position
	wait(time)
end

Put that script into the slider then insert a BodyGyro and BodyPosition into the part.

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