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

How can you stop a block lerping back to its position after it hit its target position??

Asked by
YTGonzo 20
7 years ago
Edited 7 years ago

I have a block that lerps it's self to an CFrame.new position and i need to know how to stop it wanting to lerp back to it's position after i move it.

Here's The Code:

local **Cam** = workspace.Cam -- Cam is the block and it's in its starting position

local Cam2 = CFrame.new(-34.4853897, 16.2428818, 266.647583, 0.8922984, 0, -0.451446444, 0, 1, 0, 0.451446444, 0, 0.8922984) -- **Cam2** is the place where i want to move **Cam**

local CamOrigPos = CFrame.new(-54.7339249, 16.2428818, 272.489899, 0.994100332, 0, -0.108480066, 0, 1, 0, 0.108480111, 0, 0.994100392) -- This is the **Cam** CFrame

local Button = script.Parent.Parent.Button

local BackButton = script.Parent.Parent.BackButton

local Speed = 0.5

Button.MouseButton1Click:Connect(function() -- Click Button Goes To Cam2 CFrame 
game:GetService("RunService").Heartbeat:Connect(function(step)
    Cam.CFrame = Cam.CFrame:lerp(Cam2,step/Speed)
    end)
end)

BackButton.MouseButton1Click:Connect(function() -- When Clicked It Moves A Little Bit But Then It Stops And Looks Like It Wants To Lerp Back To Cam2
game:GetService("RunService").Heartbeat:Connect(function(step)
    Cam.CFrame = Cam.CFrame:lerp(CamPos,step/Speed)
    end)

Answer this question