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

Vector3 Lerp finishing too early?

function moveCrane(route)
	for i = 1, #route do
		for a = 0, 1, 0.005 do
			crane.Position = crane.Position:Lerp(route[i].Position, a)
			wait()
			print(a)
		end
	end
end

I don't see what I'm doing wrong here, I want the block called "crane" to have it's position lerped to the specified one. It works, but not fully. Here's what I mean by that:

The part moves as you would expect from doing this, but, when the part gets to the specified location, 'a' is only at ~0.25 or something like that. To me, 'a' being at 0.25 would mean that the part would be one quarter of the way there, not already there. Maybe I'm doing something wrong. Any help is appreciated.

3 comments

0

have you tried printing the #route number? there might not be enough for the lerp to finish at that pace

0

i have tried taking the lerp for loop out of the function and the other for loop and manually specifing the goal position, and the same thing happens.

0

i fixed it, i was being dumb.

1 answer

for anyone wondering, i fixed it with this:

function moveCrane(route)
	for i = 1, #route do
		local startPos = crane.Position
		for a = 0, 1, 0.1 do
			crane.Position = startPos:Lerp(route[i].Position, a)
			wait()
			--print(a)
		end
	end
end

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