Doesn't matter where do I click on the screen it will run the command, even if its text button so I have to click on the text button the code :


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

local UIS = game:GetService("UserInputService")
local GuiVis = script.Parent.Parent.Stats

UIS.InputBegan:Connect(function(Key)
	if Key.UserInputType == Enum.UserInputType.MouseButton1 then
		if GuiVis.Visible == false then 
			
			wait()
			GuiVis.Visible = true
			script.Parent.Text = "Close"
		else
			wait()
			GuiVis.Visible = false
			script.Parent.Text = "Stats"
			
		end
	end
end)