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