Why does it print "ButtonClicked" before i have pressed the button?
local function FirstOnClick()
print("ButtonClicked")
end
TeleportationButtons.ScreenGui.First.Activated:Connect(FirstOnClick())
Why does it print "ButtonClicked" before i have pressed the button?
local function FirstOnClick()
print("ButtonClicked")
end
TeleportationButtons.ScreenGui.First.Activated:Connect(FirstOnClick())
When you want to use events you should pass a REFERENCE to the function, by adding parenthesis you invoke the function instead of referencing it:
Wrong:
TeleportationButtons.ScreenGui.First.Activated:Connect(FirstOnClick())
Correct:
TeleportationButtons.ScreenGui.First.Activated:Connect(FirstOnClick)
try out this:
local function Print(Val)
print(Val)
end
TeleportationButtons.ScreenGui.First.Activated:Connect(Print("Clicked"))
Why does the output say that i tried to print a nil value?
I will remember to accept your answer :).
The reason that was happening was because you added the parenthesis on line 5. Only include "FirstOnClick" if you do not have anything in the parenthesis and it should work.
umm
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
This is weird, try to recode it