I’m trying to make a textbutton that, when clicked, makes some UI invisible and changes a boolValue’s value. The problem is, the code isn’t firing. The script is a Local Script under the textbutton.
Can you just answer the question please? The sound is in the script. I put the script in the textbutton because the script is meant to do something when the button is clicked, but it’s not.
I believe the first thing you could try to do is instead of getting the playergui via game.Players.LocalPlayer, you use use .Parent as many times needed to go back to StarterGui, which when testing, will be PlayerGui for the script
What’s the hierachy of the StarterGui from the button?
local HoverSound = script.Parent.HoverSound
local plrGui = script.Parent.Parent.Parent.Parent --StarterGui
local Setup = plrGui.SetupWeapons
local deploybutton = script.Parent
local deploygui = script.Parent.Parent.Parent
script.Parent.MouseEnter:Connect(function()
HoverSound:Play()
print('playerd')
end)
deploybutton.MouseButton1Click:Connect(function()
print('ok')
Setup.Value = true
for i,v in pairs(deploygui:GetChildren()) do
if not v:IsA("Folder") then
v.Visible = false
end
end
print('all done')
end)
I also included a little way to make the thing you wanted to do when the button is clicked a bit more simpler to do
I managed to fix it, the ZIndex of the button was below another button, putting the ZIndex of the button that needed to be fired to around 15 made it work
Oh right, I must’ve zoned out when figuring out a way to make the code much more easier whilst also trying to think of a solution for OP and didn’t realise that what he did is the same as disabling the gui, thanks!