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

How to make ScreenGui appear on click and then go away?

This is the script I tried (I'm still kinda new to scripting)

function onClicked()
game.StarterGui.ScreenGui.Enabled = true
wait(6)
game.StarterGui.ScreenGui.Enabled = false
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 comment

0

You have to access PlayerGui not StarterGui, and when doing anything with a gui it has to be done from a LocalScript. Also use :Connect as :connect is deprecated.

1 answer

✓ Accepted answer

You have to access PlayerGui, not StarterGui. Also, use :Connect() instead of :connect() as it's deprecated.

local ClickDetector = script.Parent:WaitForChild("ClickDetector") -- Gets the ClickDetector
local GUI_Name = "ScreenGui" -- Name of GUI
local WaitTime = 6 -- Wait time before GUI wents off

ClickDetector.MouseClick:Connect(function(player)
	local GUI = player:WaitForChild("PlayerGui"):WaitForChild(GUI_Name) -- Find's the GUI
	GUI.Enabled = true
	wait(WaitTime)
	GUI.Enabled  = false
end)

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