Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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)
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. MythicalShade 420 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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)
Ad

Answer this question