Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

GUI button help?

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.

1 comment

0

Line 1 is your problem. Change it to this: closeButton = script.Parent

1 answer

✓ Accepted answer
function onClick() 
print("Pressed")
end 
script.Parent.MouseButton1Click:connect(onClick)

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

3 comments

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.

0

Never knew that (:

0

lua seems to be very flexible compared to other languages like c++

This discussion is preserved as it was. New answers, comments, and votes are closed.