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

(ANSWERED) Make a Lerp go slow to another part? How to do?

So I'm making these doors, and when you press a button with a ClickDetector in it, it will lerp the door to a duplicate door inside the wall. Anyways, my code works fine, but when it moves, it goes instantly. The tutorial I watched said to add a for loop, so I did that, but it doesn't seem to help?

My code inside the button:

local ClickDetector = script.Parent.ClickDetector
local Button = script.Parent
local Door1 = workspace.Union1
local Door2 = workspace.Union2
local DoorGoingTo1 = workspace.UnionGoTo1
local DoorGoingTo2 = workspace.UnionGoTo2

function MouseClick()
	Button.Color = Color3.fromRGB(255, 0, 0)
	for i = 0, 1, .01 do
		Door1.CFrame = Door1.CFrame:Lerp(DoorGoingTo1.CFrame, 1)
		Door2.CFrame = Door2.CFrame:Lerp(DoorGoingTo2.CFrame, 1)
	end
end

ClickDetector.MouseClick:Connect(MouseClick)

1 answer

✓ Accepted answer

You did add a for loop but whats the point of a for loops if you aren't using it and don't add a wait

local ClickDetector = script.Parent.ClickDetector
local Button = script.Parent
local Door1 = workspace.Union1
local Door2 = workspace.Union2
local DoorGoingTo1 = workspace.UnionGoTo1
local DoorGoingTo2 = workspace.UnionGoTo2

function MouseClick()
    Button.Color = Color3.fromRGB(255, 0, 0)
    for i = 0, 1, .01 do
        Door1.CFrame = Door1.CFrame:Lerp(DoorGoingTo1.CFrame, i)--you need to make it to i
        Door2.CFrame = Door2.CFrame:Lerp(DoorGoingTo2.CFrame, i)--so it changes instead of repeating a constant
	  wait(.1)--however long you want it and make sure to add waits to every loop
    end
end

ClickDetector.MouseClick:Connect(MouseClick)

1 comment

0

How silly of me, I just noticed. Thank you.

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