Why is this GUI enabler button not working?

So im currently messing around with an idea where a player can go around a map and find a button which enables a gui allowing the player to equip a face. I have got the equipping gui working easily however i for some reason cannot get the button the player has to find which enables the equipping gui to work.

I know im making a simple mistake somewhere but i have 0 clue where.

Here is the script:
local FaceButton = game.StarterGui.FaceSelection.Frame.FaceButton -- Set to gui button
local FaceIcon = game.ReplicatedStorage.Face1.Texture -- Set to face image in replicated


script.Parent.MouseClick:Connect(function() -- If the click detector detects a click then...
	FaceButton.FaceEquip.Enabled = true -- Set the script to enabled
	FaceButton.BackgroundColor = Color3.new(0,1,0)
	FaceButton.Image = FaceIcon -- Set the button to the face texture

	if FaceButton.Image == FaceIcon then
		print("Success")
		script.Parent.Parent:Destroy()
	end

end)
3 Likes

can you show the gui and the children*

2 Likes

Yes here is a screenshot of the gui:
image

1 Like

what if you were to clone the gui and then put it into player gui with an already active script

1 Like

Having an already active script would ruin the purpose of having to find the button to enable it.

1 Like

oh, ik this may be over complicated but here

what if you make remote event and then connect (bind isnt a great word) it to the script
and then make it so when the remote event is fired you do what ever in your local script

1 Like

Try right clicking the script and enabling it

he wants the enable the script with another

That script is disabled so it wont run

Ohh ok that makes sence so he can enable that script

this script you want to enable will pop up a gui?

i just found your problem, your finding the gui in screen gui, not the players gui

local FaceButton = game.StarterGui.FaceSelection.Frame.FaceButton – Set to gui button
local FaceIcon = game.ReplicatedStorage.Face1.Texture – Set to face image in replicated

you have to change the script to:

script.Parent.MouseClick:Connect(function(plr)
local FaceButton = plr.PlayerGui.FaceSelection.Frame.FaceButton -- Set to gui button
local FaceIcon = game.ReplicatedStorage.Face1.Texture -- Set to face image in replicated
	FaceButton.FaceEquip.Enabled = true -- Set the script to enabled
	FaceButton.BackgroundColor = Color3.new(0,1,0)
	FaceButton.Image = FaceIcon -- Set the button to the face texture

	if FaceButton.Image == FaceIcon then
		print("Success")
		script.Parent.Parent:Destroy()
	end

end)

(I JUST EDITED THE SCRIPT AGAIN BTW)

1 Like

Can confirm should work well im mad o didnt find that

I’ve actually edited the script since to make it find the players gui not the screen gui. I have also found that it’s a problem in detecting the click/touch (i’ve tested both touch part and click now) as nothing comes out in the output when i call for a print when the function is run.

It still dosent work as well even after changing this*

is it working?
aaaaaaaaaaaaaaa

are you expecting for the localscript to run when you click a button?

The script should fire the function when the scripts parent (a part) is clicked/touched.

Does it work???

As stated before no, it does not.

You just missed a 3 after BackgroundColor!

local FaceButton = game.StarterGui.FaceSelection.Frame.FaceButton -- Set to gui button
local FaceIcon = game.ReplicatedStorage.Face1.Texture -- Set to face image in replicated


script.Parent.MouseClick:Connect(function() -- If the click detector detects a click then...
	FaceButton.FaceEquip.Enabled = true -- Set the script to enabled
	FaceButton.BackgroundColor3 = Color3.new(0,1,0)
	FaceButton.Image = FaceIcon -- Set the button to the face texture

	if FaceButton.Image == FaceIcon then
		print("Success")
		script.Parent.Parent:Destroy()
	end

end)