The method below you are using:
local part = script.Parent
for i = 0,1,0.01 do wait()
part.CFrame = part.CFrame:Lerp(CFrame.new(177.5,0.5,4.5),i)
wait(0.1)
end
for i = 0,1,0.01 do wait()
part.CFrame = part.CFrame:Lerp(CFrame.new(177.5,0.5,21),i)
wait(0.1)
end
Is pretty ugly, you would have to mess around until you get what you want and its a bit blocky... I prefer tween, I even made my own function, here I'll give you a sample:
local function tween(Part,Prop,Val,timing,TweenType)
local TweenService = game:GetService("TweenService")
local goal = {}
goal[Prop] = Val
if timing then
local tweenInfo
if TweenType then
tweenInfo = TweenInfo.new(timing,Enum.EasingStyle[TweenType])
else
tweenInfo = TweenInfo.new(timing)
end
tweenn = TweenService:Create(Part, tweenInfo, goal)
else
local tweenInfo = TweenInfo.new(5)
tweenn = TweenService:Create(Part, tweenInfo, goal)
end
return tweenn:Play()
end
tween(part,"Position",CFrame.new(177.5,0.5,4.5),1)
wait(1)
tween(part,"Position",CFrame.new(177.5,0.5,21),1)
You can even customize the tween type..
Since it can be used multiple times without yielding, you would need to add a wait to it. Enjoy, if this works click accept.
1 comment
It is because the loop is not yet finished reaching 1. In order to make it faster, you can increase the increments of your loop. Doing so however, will make the lerp faster.