GUI Activation on Click

I would like to have it to where once I click the click detector the GUI opens and becomes visible but cannot do so

Once I click on the click detector, the GUI simply does not open up, this GUI is located in the starter GUI.

I have attempted to look around, but couldn’t find any solutions tailored to my script, I attempted moving the local scripts around but didn’t get any progress.

local shopGUI = game.StarterGui.DealerGUI.ShopGUI
local clickdetector = script.Parent.ClickDetector

script.Parent.ClickDetector.MouseClick:Connect(function()
	shopGUI.Visible = true
end)

Assuming this is a SERVER script, you must use the player parameter that MouseClick provides to make the gui visible. Also, startergui gets replicated into PlayerGui for every player, it’s useless to try and set variables for startergui.

Assuming this is a CLIENT script, I’m not sure if these events fire on the client, you could make a remote event on the server and fire it or just do what I said above. Make sure whenever defining gui variables you do:

game.Players.Player.PlayerGui
or
player.PlayerGui

1 Like

You should get the PlayerGui not StarterGui
Maybe by modifying the script like this:

local clickdetector = script.Parent.ClickDetector

script.Parent.ClickDetector.MouseClick:Connect(function(hit)
local plr = game.Players:FindFirstChild(hit.Parent)
local shopGUI = plr.StarterGui.DealerGUI.ShopGUI
shopGUI.Visible = true
end)

Ill give that a shot and see how it works

That makes no sense? MouseClick provides the player, not whatever “hit” is. And you still have it as plr.StarterGui?

1 Like

I don’t remember exactly how it works. i’ll go check it out

You were right, I modified the script and now it works.

local clickdetector = script.Parent.ClickDetector

clickdetector.MouseClick:Connect(function(plr)
local shopGUI = plr.PlayerGui:FindFirstChild(“DealerGUI”).ShopGUI
shopGUI.Visible = true
end)

1 Like

Didnt work, I think the script has to be in the GUI itself?

Ill keep that in mind, I don’t want everyone seeing the GUI when it’s clicked by one person lol

I just tried it and it works, The gui must be in StarterGui.

Can you show me the output? are there any errors?

Nothing in output, but I am using a local script

You should use a normal script

this is the script now

local shopGUI = game.StarterGui.DealerGUI.ShopGUI
local clickdetector = script.Parent.ClickDetector

clickdetector.MouseClick:Connect(function(plr)
	local shopGUI = plr.PlayerGui:FindFirstChild("DealerGUI").ShopGUI
	shopGUI = true
end)

wait a minute I see my mistake

It doesn’t work

  1. You can’t make a gui visible directly from starter gui, so the first string is useless

local shopGUI = game.StarterGui.DealerGUI.ShopGUI

  1. In the sixth line you forgot to add .Visible
    shopGUI.VIsible = true

The script script I gave you should work.

local clickdetector = script.Parent.ClickDetector

clickdetector.MouseClick:Connect(function(plr)
local shopGUI = plr.PlayerGui:FindFirstChild(“DealerGUI”).ShopGUI
shopGUI.Visible = true
end)

Do I have this as a normal script or a local script?

It must be a normal script.
Don’t worry it still only works for the player who clicks

I am not actually using a block for the click detector, it’s in a humanoids torso

It should work even if it’s a torso, but to be sure I recommend putting the script inside a part around the whole character