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 a GUI pop up when brick is clicked?

Code I have so far:

script.Parent.ClickDetector.MouseClick:Connect(function(Player)
Player.PlayerGUI.AreYouSureGUI.Frame.Visible = true
end)

I know this question has been asked and answered a lot, but trying those solutions would not work! I get this error:

PlayerGUI is not a valid member of Player

What am I doing wrong here?

3 comments

0

click detectors only work from remote events now, what you would need to do is have a script in server listening for your click detector to be clicked on, then fire the event client side and have your gui show up from a local script. if you need me to go more in depth just let me know

0

where would i put the remote event? replicated storage?

0

yes

1 answer

✓ Accepted answer

What I did was I used a RemoteEvent, a script in the brick, and a local script in the GUI.

For the script inside the brick I did this:

local replicatedStorage = game:GetService("ReplicatedStorage")
local event = replicatedStorage:WaitForChild("ShowGUI") --The RemoteEvent is named "ShowGUI"

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	event:FireClient(player) --Sending a message through the RemoteEvent to change the GUI
end)

Then, with the local script inside the ScreenGui, I did this:

local replicatedStorage = game:GetService("ReplicatedStorage")
local event = replicatedStorage:WaitForChild("ShowGUI")

event.OnClientEvent:Connect(function(player)
	game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = not game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible --(I just did this to make it so it would be like a on / off button, you can change the right side of the equals to "true" if you want it to just be a once-activated thing.)
end)

This worked for me, I hope it works for you!

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