I'm trying to make a part move when the player presses the A key and I want to use linear interpolation to do it, which I'm not very familiar with. The code below moves the part to the desired position but then pauses for a few seconds before it can move again, and I'm not really sure why. How do I make the part move continuously?
function lerp(direction)
local pos = a.Position + Vector3.new(50,0,0)
for i = 1,100 do
if holdingA == true then
local alpha = i/100
a.Position = a.Position:Lerp(pos, alpha)
print(pos)
wait()
end
end
end
uis.InputBegan:connect(function(inputObject)
if inputObject.KeyCode == Enum.KeyCode.A then
holdingA = true
while holdingA do
lerp()
wait()
end
end
end)
uis.InputEnded:connect(function(inputObject)
if inputObject.KeyCode == Enum.KeyCode.A then
holdingA = false
end
end)

6 comments
since you are waiting in the lerp fuction you do not need a wait on the while loop. you also should break out fo the loops when holdingA is false.
Your lerp function should be from start to end position. You use a.Position each time which changes store the start position in a variable and use that.
Thanks so much!
shouldn't lerp() be called from a.Position.CFrame?
just sayin'
lerp also works for Vector3s