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

How can I make this part wait less time before going back?

i mean it waits like 5 sec before going back and dont know why `> 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` Any sugestions? :<

1 comment

0

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.

1 answer

✓ Accepted answer

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.

2 comments

0

thanks :D i will remember! wish u luck.

0

you too

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