Make GUI appear on players screens every 10 SEC?

Hi i am trying to make a GUI appear on all players in server screens every 10 seconds.

I currently have this code

local Players = game:GetService("Players")
local player = Players.LocalPlayer


game.StarterGui.WannaSkip.TextLabel.Visible = false

while wait(10) do
	
	for i,v in pairs(game.Players:GetChildren()) do
		
		game.StarterGui.WannaSkip.TextLabel.Visible = true
		
		
		
	end
	
	
end

Im assuming i’d have to use a while loop but when reading other posts it says different but then i cant seem to make any code do what i want.

Any ideas? Thankyou!!

2 Likes

You’re using StarterGui, get the PlayerGui and edit the Visibility through there.

1 Like

is this what you mean?

local Players = game:GetService("Players")
local player = Players.LocalPlayer

for i, player in ipairs(Players:GetPlayers()) do
	task.spawn(function()
		local PlayerGui = player:WaitForChild("PlayerGui")


while wait(10) do
	
		
			PlayerGui.WannaSkip.TextLabel.Visible = true
			
			wait(3)
			
			PlayerGui.WannaSkip.TextLabel.Visible = false
		
		
		
	end

end)
	
end
	
2 Likes

Why did you set the value name to “player” in for i, player in [...] and added a variable named, local player = Players.LocalPlayer?

1 Like

fixed by using this code

--//Services
local Players = game:GetService("Players")


--//Functions
local function DisplayUI(playerName)
	for i, player in ipairs(Players:GetPlayers()) do
		task.spawn(function()
			local PlayerGui = player:WaitForChild("PlayerGui")
			PlayerGui.WannaSkip.TextLabel.Visible = true

			task.wait(10)
			PlayerGui.WannaSkip.TextLabel.Visible = false
		end)
	end
end

Players.PlayerAdded:Connect(function(player)

while wait(490) do
			DisplayUI(player.Name)
		end
	end)

You could simply do:

local plr = game.Players.LocalPlayer
local PlayerGui = plr:WaitForChild("PlayerGui")

local UI = PlayerGui:WaitForChild("WannaSkip").TextLabel

while wait(10) do
	UI.Visible = true
	wait(3)
	UI.Frame.Visible = false
end

in a localscript in starterplayerscripts.
or just add a localscript in the textlabel itself and do a loop that appear every 10s

2 Likes