Button not working

yo

What do you want to achieve? A working fricking button

What is the issue? The script for some reason doesn’t WORK

What solutions have you tried so far? look i’ve tried using this

local clickDetector = workspace.Button.ClickDetector

function onMouseClick()
print(“You clicked the button wow that was pretty useless!”)

end

clickDetector.MouseClick:connect(onMouseClick)
give me solution.

and this time I also want the EXPLANATION.

try this

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)
1 Like

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.

1 Like

“workspace” is the same as “game.Workspace”

1 Like

ok you just add an agrs xD it will result the same

1 Like

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!
2 Likes

I think because you are using this ” instead of this " and you don’t have to Capatalize the Connect but you can if you want.

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. :slightly_smiling_face:

1 Like

The button wont work isn’t a good description. Any errors or what?

You have to capitalize it… Give it a try yourself.

I’ve already try it, and it worked properly

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

Dude, I’ve already try it, maybe you should try it yourself.

Bruh, Sorry I actually just tried it but It is probably best to use :Connect

Is this on a script? try changing it to a local script if so. I can’t see any other problem that may be causing the issue.

Yes, I use it capitalized but just saying.

ok i’ve tried all the solution but for some reason it still doesn’t work??

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)

Does this work?

image

1 Like

yeah i did that and it didn’t work

Is it local script or script? Just to make sure.