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

How do I make a GUI show when a player clicks a ClickDetector?

Asked by 10 years ago

It's pretty simple, I just want a GUI to show to the player when they click a ClickDetector. Here's what I tried:

local Frame = game.PlayerGui.ScreenGui.Background

function onClick()


Frame.Visible = true

end

script.Parent.MouseButton1Click:connect(onClick)

1 answer

Log in to vote
3
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

Nice try. For a ClickDetector, you need to use the MouseClick event, and from that function, you can get the actual Player.

script.Parent.MouseClick:connect(function(p) -- Make sure it leads to the ClickDetector
    p.PlayerGui.ScreenGui.Background.Visible = true
end)
Ad

Answer this question