Ive tried looking this up but everything i see is when a character STEPS on the brick, i just want the gui to pop up after the player clicks the block (in my case its a book).
How to make a gui pop up when player CLICKS a block?
2 answers
I'll just send you the script here, make sure to look into it because I made it for you for free.
local Click = script.Parent.Click
function Clicked()
local plr = game.Players:FindFirstChild(game.Players.LocalPlayer.Name)
plr.PlayerGui.ScreenGui.Frame.Visible = true
end
Click.MouseClick:connect(Clicked)
This should work, just make sure to reroute some variables so it works.
To do this, you need to place a ClickDetector into the block itself. You can read more about those here.
Once that is added, you need to add a script under the ClickDetector that fires whenever it is activated through a mouse click. Below is the example used by Roblox.
local clickDetector = workspace.Part.ClickDetector
function onMouseClick()
print("You clicked me!")
end
clickDetector.MouseClick:connect(onMouseClick)
Alternatively, you can replace the clickDetector variable to just have script.Parent. Either way, they can work but it gets kinda messy if you have multiple blocks with click detectors. That's why I'd use the script.Parent method.
If this helped you out, consider accepting this answer for those sweet, sweet reputation points. If not, comment below and I (or someone else) will help you out.
Be sure to check out the Roblox API Documentation as well for additional reference.
2 comments
so in the function mouse click instead of "print me" i can set the gui visibility to true?
Yes, you can insert whatever code you want to be ran. Here's a helpful tip, the MouseClick event has a parameter of the player that activated the click. So you can use function onMouseClick(plr) where plr would be referring to the Player that clicked the part. It makes life easy.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
so how could i change which specific gui to open?
and it doesnt work, i get an error on line 4, something about the (.Name)