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

How to open GUI with a click detector?

Asked by 6 years ago

So I've been having some trouble with my script recently. I made a part with a click detector and inserted a script into the click detector so that it would open a GUI. This is the script:

script.Parent.MouseClick:connect(function() game.StarterGui.CODEN.VERIFICATION.Visible=true end)

--CODEN is the screen GUI and VERIFICATION is the frame

Please PM my profile(YieldingSweetblade) to contact me about this. You have to follow me to message me (feel free to unfollow me once you are done).

0
Actually, forget the whole PM part. You can answer in the comments. YieldingSweetblade 5 — 6y
0
Addition to Thee's answer, it's more efficient to do things on Local for Gui's health. Put a LocalScript in Gui, give a specific name to object that holds clickdetector, then connect it via there. superalp1111 662 — 6y

3 answers

Log in to vote
2
Answered by 6 years ago

I am pretty experienced with Filtering Enabled, so I am glad to help. Also I have tested this in Filtering Enabled an it is working!

First of all you need to create a script, I recommend putting it inside "ServerScriptService", Next you need to create a "Remote Event" inside of "ReplicatedStorage" Name the Remote Event: "ShowGui"

Now copy this:

local part = game.Workspace.PARTNAMEHERE

local rstorage = game:GetService("ReplicatedStorage")
local showgui = rstorage.ShowGui

part.ClickDetector.MouseClick:connect(function(player)
    showgui:FireClient(player)
end)

Next, create a LocalScript inside of your ScreenGui.(make sure it is in ScreenGui, NOT a frame.) Now copy this code:

local rstorage = game:GetService("ReplicatedStorage")
local showgui = rstorage.ShowGui

showgui.OnClientEvent:connect(function()
    script.Parent.Enabled = true
end)

If you still need help, contact me. (I have Discord)

Ad
Log in to vote
1
Answered by
TheePBHST 154
6 years ago
Edited 6 years ago

Your script only makes that GUI Visible as a StarterGui. StarterGui is basically a Gui that is always shown on the players screen as it is set in the StarterGui. So, you're gonna need to access the player's PlayerGui and make it visible from there.

You should do..

script.Parent.ClickDetector:Connect(function(plr)
    plr.PlayerGui.CODEN.VERIFICATION.Visible = true
end)
0
That's right but it's a fact that it wouldn't work in FE. I assume he does not have FE on but it's best to tell things in that way. superalp1111 662 — 6y
0
Thanks, it worked YieldingSweetblade 5 — 6y
0
You know you should verify that this answer is correct to gain more rep. (your choice, not begging) TheePBHST 154 — 6y
Log in to vote
0
Answered by 6 years ago

Thee's answer is right but it wouldn't fit for FilteringEnabled purposes. You can insert a LocalScript to Gui and give a specific name to object holding ClickDetector. Tben do the connection. Example for a localscript inside ScreenGui:

game.Workspace.SPECIFICNAME.ClickDetector.MouseClick:Connect(function()
    script.Parent.VERIFICATION.Visible = true
end)

Although, this would be more efficient but not the most because finding an object via game.Workspace is not a good way to find something. Using a remote to fire an event when it have been clicked or sending itself as an object variable as a parameter by firing an object after character spawns for this kind of thing would be better but it's confusing for beginners. Research it when you feel ready. Until that, use this.

0
You don't need remote events for clickdetectors TheePBHST 154 — 6y

Answer this question