Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GUI button help?

Asked by 9 years ago

I am trying to figure out why roblox is not reading when the button is pressed, the script is a local script.

 closeButton = Parent

closeButton.MouseButton1Down:connect(function()
    print"pressed"
end)

It does not print anything.

0
Line 1 is your problem. Change it to this: closeButton = script.Parent NoahWillCode 370 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago
function onClick() 
print("Pressed")
end 
script.Parent.MouseButton1Click:connect(onClick)

You also wrote print"pressed" instead of print("pressed") <-Works either way

0
Okay, so, "Parent" was wrong. He should have used "script.Parent" But jay, print"Pressed" is just as legal as print("Pressed"). Lua is flexible like that. The parentheses are just better to use for readability, as well as in special cases when they are necessary. NoahWillCode 370 — 9y
0
Never knew that (: jaytheidiot 60 — 9y
0
lua seems to be very flexible compared to other languages like c++ CaptainRuno 40 — 9y
Ad

Answer this question