UI button script not working

I’ ve tried that when you press a button in a screengui then the mousebutton goes away but it doesn’t work and I don’t know why?

a.MouseButton1Click:connect(function()
local USB = game:GetService("UserInputService")
USB.MouseIconEnabled = false
end)

(a is the variable for the button in the screengui)
(the script is in the server script service)

Put it as a localscript in the button and change your a variable to be local a = script.Parent. UserInputService only works in localscripts

4 Likes

please make sure to put the problem in the title

2 Likes