Tween Delay [HELP PLEASE]

Hello there guys!
could you please help me fix my script?
problem: the tween is delayed

Script:

local TS = game:GetService("TweenService")

local guiname = script.BattleName.Value
local now = "Tix"

local myspinamout = math.random(5,10)
local myspin = myspinamout	


for i,v in pairs(game.Players:GetChildren()) do
		local mypart = v.PlayerGui.ScreenGui.Frame[guiname].ViewportFrame.Part
		local a = TS:Create(mypart, TweenInfo.new(1), {Orientation = mypart.Orientation + Vector3.new(0, 180, 0)})
	    a:Play()
	    a.Completed:Wait()
		if now == "Tix" then
			now = "Bux" 
		else
			now = "Tix"
		end
end

Its because you are waiting for tween to finish before playing the tween for the next player, looking at your code it seems unnecessary to have that wait, so you could just remove a.Completed:Wait() and move the if statement out of the for loop. If you really need it to be in the loop then you can just wrap everything inside the loop in a coroutine like this:

coroutine.wrap(function()
     --your code
)()

I gotta have the a.Completed:Wait() in the script else
the tween will move fast

I guess you can just warp it with spawn(function()

local TS = game:GetService("TweenService")

local guiname = script.BattleName.Value
local now = "Tix"

local myspinamout = math.random(5,10)
local myspin = myspinamout	


for i,v in pairs(game.Players:GetChildren()) do
     spawn(function()
		local mypart = v.PlayerGui.ScreenGui.Frame[guiname].ViewportFrame.Part
		local a = TS:Create(mypart, TweenInfo.new(1), {Orientation = mypart.Orientation + Vector3.new(0, 180, 0)})
	    a:Play()
	    a.Completed:Wait()
		if now == "Tix" then
			now = "Bux" 
		else
			now = "Tix"
		end
    end)
end
1 Like

THANK YOU SO MUCH MAN

1 Like