Code issues - Screengui 10 seconds (true) then disappears (false)

How can I make the screengui active when the player joins for 10 seconds and then disappears?

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)

print(player.Name .. " joined the game!")

wait(10)

game.StarterGui.MainMenu.Enabled = false

end)

image

Could someone help me with that please :frowning:

1 Like

For LocalScripts, you don’t need to use PlayerAdded since LocalScripts run when the player is added already.

To actually edit UI properties, you’re going to have to access PlayerGui, which is under the LocalPlayer. Or, you can simply use script.Parent:WaitForChild("childName").

In a nutshell, all objects in StarterGui are cloned and parented to PlayerGui.

It should be something like this:

local Players = game:GetService("Players")

local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local mainMenu = playerGui:WaitForChild("MainMenu")

print(player.Name .. " joined the game!")
wait(10)
mainMenu.Enabled = false
1 Like