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

Gui Tweening not working in game round script?

 for i = 120,0,-1 do
        status.Value = "Game In Progress:"..i

if game.ReplicatedStorage.Finished.Value == "yes" then	
	game.ReplicatedStorage.Finished.Value = "No"
	for _,plr in pairs(game.Players:GetPlayers()) do
		meep = plr.PlayerGui.ScreenGui.Frame
        plr.PlayerGui.ScreenGui.Frame.Visible = true
        meep:TweenPosition(UDim2.new(0,0,0.5,0),'In','Linear',1)
	end
	wait(5)
	for _,plr in pairs(game.Players:GetPlayers()) do
		meep:TweenPosition(UDim2.new(1,0,0.5,0),'Out','Linear',1)
        plr.PlayerGui.ScreenGui.Frame.Visible = false
Fin.Value = "NO"
 Win.Value = "NahBoi"
	end
	break

So this is the code for a game round. If the finished string value is yes, the round stops and a gui comes in, waits 5 seconds, then goes out. The first tween works, the second one doesn't. Can someone help?

1 answer

✓ Accepted answer

You have to redefine the 'meep' variable in your second loop. Otherwise, it will be equivalent to the last iteration in the previous loop.

######note: remember to use variables in order to keep your code clean and concise!

local finished = game.ReplicatedStorage.Finished

 for i = 120,0,-1 do
	status.Value = "Game In Progress:"..i
	if finished.Value == "yes" then  
		finished.Value = "no"
		for _,plr in pairs(game.Players:GetPlayers()) do
			local meep = plr.PlayerGui.ScreenGui.Frame
			meep.Visible = true
			meep:TweenPosition(UDim2.new(0,0,0.5,0),'In','Linear',1)
		end
		wait(5)
		for _,plr in pairs(game.Players:GetPlayers()) do
			local meep = plr.PlayerGui.ScreenGui.Frame --redefine mate
			meep:TweenPosition(UDim2.new(1,0,0.5,0),'Out','Linear',1)
			plr.PlayerGui.ScreenGui.Frame.Visible = false
		end
		Fin.Value = "NO"
		Win.Value = "NahBoi"
	end
end

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