local clickDetector = workspace.Button.ClickDetector
function onMouseClick(plr)
print(plr.Name..", You clicked the button wow that was pretty useless!")
end
clickDetector.MouseClick:Connect(onMouseClick)
I don’t know how you set up the script but when I placed it in a server script it worked fine for me. Double check and ensure that everything’s named properly and there aren’t duplicate “Buttons” in the workspace.
You forgot to capitalize the :Connect when you connected the ClickDetector to the function OnMouseClick(), by the way, capitalization matters in LUA so make sure you enable the Autocomplete feature, If you want to enable it then go to File then Studio settings then Script Editor then search for Autocomplete and enable it if you want.
local clickDetector = game.Workspace.Button.ClickDetector
function onMouseClick()
print(“You clicked the button wow that was pretty useless!”)
end
clickDetector.MouseClick:Connect(onMouseClick) -- Capatalize the Connect!
local clickDetector = game.Workspace:WaitForChild("Button").ClickDetector
local function onMouseClick()
print(“You clicked the button wow that was pretty useless!”)
end
clickDetector.MouseClick:Connect(onMouseClick)
Functions should almost always be local, as well as Connect being uppercase. I added the WaitForChild, simply to see if it exists. If it errors ("Infinite yield possible on “game.Workspace:WaitForChild(“Button”)”), then “Button” doesn’t exist and that’s another problem.
Cause you had it capitalized, Get a button and try doing the :connect without capitalizing it like this :Connect Also Roblox’s automatic auto-completion clearly says :Connect and not :connect
local clickDetector = game.Workspace:WaitForChild("Button").ClickDetector
local function onMouseClick()
print("You clicked the button wow that was pretty useless!") -- "" instead of “”
end
clickDetector.MouseClick:Connect(onMouseClick)