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

Why is my script not working that removed the gui after 5 seconds?

i was making a script in the server script service that removes the gui after 5 seconds the error i got is KeyDownGui is not a valid member of Startergui Heres the script


if game.ChildAdded then --- checks if the player is added
	wait(5)
	game.StarterGui.KeyDownGui:remove()
end

1 answer

Deleting a gui from the StarterGui does not delete it for all players, I recommend removing it from each player and after they joined using the ChildAdded event.

game.Players.ChildAdded:connect(function(player)
	wait(5)
	if player and player.PlayerGui then
		local gui = player.PlayerGui:FindFirstChild'KeyDownGui'
		if gui ~= nil then
			gui:remove()
		end
	end
end)

I hope this helped!

4 comments

0

Your description does not match your code. You're not 'cycling' through Players (as that implies a loop), but the end result does match OP's goal.

0

Originally It was going to be a for loop, but I just changed it to be worded correctly.

0

dosent work

0

Not quite sure what you mean. I just tested it and it works perfectly. Try placing it in ServerScriptService as a Script

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