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

How would I break a CFrame:Lerp when another CFrame:Lerp happens?

For example, say a part is being lerped from CFrame.new(0,0,0) to CFrame.new(0, 10, 0). In the middle of the lerp, another lerp would be triggered that would send the part back to CFrame.new(0,0,0). These lerps would interfere with eachother. How would I make it so when the second lerp is triggered the first lerp loop would break? I assume I would have to use variables but I am not sure where to put them.

1 comment

0

Can you post the code where you are lerping the CFrame? The best answer depends on how your code is written.

1 answer

✓ Accepted answer

Haven't tested this, try this and see how it works

local lerpKey = 0
function lerp(part,cf)
	lerpKey = math.random()
	local oldKey = lerpKey
	for i = 0,1,0.001 do
		if oldKey ~= lerpKey then break end
		-- Lerp things here
	end
end

2 comments

0

Thanks! I think this fixed it.

0

why the downvote?

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