ImageButton not clickable?

So, I’m trying to make a simple music system for a club. I was going to add a mute button, but I noticed that this MouseButton1Click event is not firing.

local player = game.Players.LocalPlayer
local playerGUI = player:WaitForChild("PlayerGui", math.huge)
local musicGUI = playerGUI:WaitForChild("Music", math.huge)
local musicLabel = musicGUI:WaitForChild("MusicLabel", math.huge)
local muteButton = musicGUI:WaitForChild("MuteButton", math.huge)

muteButton.MouseButton1Click:Connect(function()
    print("clicked mute")
end)

This is not my entire script. This is just the section that involves the mute button. The rest of the script is not important. all it does is choose a random song and plays it. It shouldn’t have any effect on the button.

Edit: Forgot too say that there are no errors in my output. It’s just not printing.

1 Like

Maybe because MuteButton is still

nil

try

local player = game.Players.LocalPlayer
local playerGUI = player:FindFirstChild("PlayerGui", math.huge)
local musicGUI = playerGUI:FindFirstWaitForChild("Music", math.huge)
local musicLabel = musicGUI:FindFirstChild("MusicLabel", math.huge)
local muteButton = musicGUI:FindFirstChild("MuteButton", math.huge)
if muteButton then
print("found it bois")
end
muteButton.MouseButton1Click:Connect(function()
    print("clicked mute")
end)

That shouldn’t be an issue. I double checked the name’s of all my UI. It should find it, since I’m using a WaitForChild()

Maybe it could not find the mutebutton

Try adding this then see did the system get the mutebutton

if muteButton == nil then
    print("couldnt find button")
else
    print("found button")
end

Its not the studio problem its in-game problem and your using WaitForChild, meaning if it cant find it, it will keep waiting. That may be the reason why the script doesn’t go down and read the rest

But it is finding it. I have the event at the bottom of my script. Above the event, I have the code that chooses a random song and plays. Which means it is finding the button, and continuing the script.

Wait…i think I just realized why it’s not working though. I’m using a while wait() do loop to choose songs infinitely. Since my event is at the bottom, the infinite loop is preventing my script from reaching the event.

1 Like

lol, thanks for trying to help me. i appreciate it.

1 Like