Task.wait seems to be faster at startup

Hello there,
just now I wrote a little script to start 3 identical tweens for 3 parts with each one being one second appart from another. This works fine in RUN(F8) mode, but as soon as I Play the game via the Roblox Player or Roblox Studio, the first two tweens always have a shorter delay between each other, with the 3rd tween seeming to be executed at the right time.
This behavior persists even when adding more tweens after the third one. I tried it with up to 6 and the first two tweens were still executed faster after each other, whilst the rest had the 1 second delay applied correctly.

Expected Behavior:

Actual Behavior:

The Code responsible for creating, running and delaying the different tweens

----- >>     Gather all child parts     << -----
    for i, part in instance:GetChildren() do -- gets all children of a folder, but only uses parts
        if part:IsA("Part") and self.parts[part.Name] == nil then -- no duplicate names allowed
            self.parts[tonumber(part.Name)] = part -- "tonumber" is here for the blocks to tween in the correct order
        end
    end

    ----- >>     Tweem Logic     << ----- slideDistance is the distance the parts are supposed to travel in the direction they are facing
    local tweenInfo = TweenInfo.new(slideDistance/2, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut, -1, true, pause) -- pause is usually set to a variable = 0
    for i, part in self.parts do
        self.tweens[tonumber(part.Name)] = TweenService:Create(part, tweenInfo, {CFrame = self.parts[tonumber(part.Name)].CFrame + self.parts[tonumber(part.Name)].CFrame.LookVector * slideDistance}) 
        self.tweens[tonumber(part.Name)]:Play() -- tweens are stored in a table for easily canceling them if they are no longer needed
        task.wait(1) -- normally set to a variable
    end

When executing this code a few seconds later, it also works like intendet. The problem seems to be connected with how Roblox handles starting scripts.

Maybe somebody already had this problem or you might know how to fix this. I´m already grateful for your response.
Have a nice day

Hey, is the Tween Script on the Server ?

If it is you should make it Client Sided like that it wont be this floppy aswell, once your Ping gets bad the Tweens wont work at all because of the Replication between Server - Client. Usually u can see a bit Unsmoothness in the Studio aswell when you Compare the Server and Client View.

The Main Reason for the Delay might be the Freeze when you load in as the Player (in Studio) because your PC is actually running the Server in Studio.

2 Likes

This could be the exact cause;

This problem is mentioned by suphi in his recent video (i think part 2)
You can (and should) just tween those objects on the client instead

1 Like

Thank you very much!
I´d like so select both of your answers as the solution, but thats sadly not possible.

You should select Noel’s, they were first afterall

2 Likes