:MouseButton1Click() not working

Mouse button 1 click doesn’t work even when I change the script a lot:

It is a text button.

Solutions I have tried:

  1. Checking if it is being covered by another gui
  2. Restarting studio
  3. Checking if its a local script (which it is)
  4. Checking if its the right button (it is)
  5. Checking if its a button (i have)
  6. Checking output for anything
  7. Making the ZIndex high

It works for every other button but i dont know why it doesnt work for this one

StarterGUI.CharacterCustomization.CustomizationFrame.ExitButton.MouseButton1Click:Connect(function()
	print("Exit")
	StarterGUI.CharacterCustomization.CustomizationFrame.Visible = false
	MainUI.PlayerStatsBackground.Visible = true
	Process = false
	updateStats() 
end)
1 Like

Is it initialized yet?
It could be a problem where the button is not fully loaded.
Any errors appear when you start studio, from the local script that manages the button?

youre checking for clicks on the button thats in StarterGui
when your character spawns all UI gets cloned from StarterGui to LocalPlayer.PlayerGui

local PlayerGui = game:GetService("Players").LocalPlayer.PlayerGui

PlayerGui.CharacterCustomization.CustomizationFrame.ExitButton.MouseButton1Click:Connect(function()
	print("Exit")
	StarterGUI.CharacterCustomization.CustomizationFrame.Visible = false
	MainUI.PlayerStatsBackground.Visible = true
	Process = false
	updateStats() 
end)
1 Like

i think it’s because you’re referencing the button directly from StarterGui and not from PlayerGui

you should reference all your gui instances through PlayerGui for them to function properly

try replacing StarterGUI with game.Players.LocalPlayer.PlayerGui and see if it fixes your problem

1 Like