This is an example code:
function Play() Print("Bruh") end game.Players.LocalPlayer.PlayerGui.ScreenGui.Button.MouseButton1Click:Connect(Play)
I don't know what I'm doing wrong, when I press the button nothing happens, and I need to get my mouse off of the button before I can click it again.
Make sure it's a local script and you can just put the local script inside the button then do
local button = script.Parent--finds the button easily without having to start at game.Players function announce() print("Bruh") end button.MouseButton1Click:Connect(function() announce() end)
do you get any errors? if yes then tell us, try this
function Play() Print("Bruh") end game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("Button").MouseButton1Click:Connect(Play)
the function :WaitForChild("Child name") will wait untill the object is loaded, because if it try to find it but the object is not there then it will error. Also make sure that it is a local script.