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

Can you lerp a union? Because it's not working for me

I'm trying to lerp a union and it doesn't work. Here is my script:


for i = 1,5,1 do wait() script.Parent.CFrame = script.Parent.CFrame:Lerp(script.Parent.CFrame,i) end

1 answer

✓ Accepted answer

Yes, you can. Think of the the first parameter for Lerp() being the CFrame position you want to end up at. Think of the second parameter as being a percent in decimal form.

(.1 is 10%, .2 is 20%, .3 is 30% etc)

If your first parameter is CFrame.new(0,5,0) and your second parameter is .5, that means your unions position will be 50% of the way to CFrame.new(0,5,0) which is CFrame.new(0,0.25,0)

Here's a code example where a union moves 10% of the way to it's destination every second:

union = script.Parent
start = union.CFrame -- our start position is the unions current CFrame
_end= union.CFrame * CFrame.new(0,20,0) --our end destination is 20 studs up in the air

for i = 0, 1, .1 do
	wait()
	union.CFrame = start:Lerp(_end, i) 
end

A gif of the code in action

Here's your code:

for i = 1,5,1 do
	wait(.1) 
	script.Parent.CFrame = script.Parent.CFrame:Lerp(script.Parent.CFrame,i) 
end

Your code is telling the union to move 100-500% of the unions

Your loop is also lerping the brick 1-5 which means the brick is lerping...

100% of the bricks position wait() 200% of the bricks position wait() 300% of the bricks position wait() 400% of the bricks position wait() 500% of the bricks position

this will move the brick, but it will end up at 5x of it's original position which I'm not sure is what you meant for.

If this isn't the issue, let me know what is happening and what you expect to happen.

2 comments

0

Wow thank you! It worked!

0

cheers

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