How do i make this work? Yet it does nothing and i get this error in the output :11: attempt to call field 'MouseEnter' (a userdata value)
text = script.Parent.Parent.TextLabel function OnOver() text.Text = "random text" end function OffOver() text.Text = "random text2" end script.Parent.MouseEnter(OnOver) script.Parent.MouseLeave(OffOver)
text = script.Parent.Parent.TextLabel function OnOver() text.Text = "random text" end function OffOver() text.Text = "random text2" end script.Parent.MouseEnter:connect(OnOver()) script.Parent.MouseLeave:connect(OffOver())
you forgot to connect the events to the functions
Problem:
Simple mistake; you're simply forgetting the connect method
that's required to bind functions
with events
. This method is called from the event of the object, and the argument passed through the method is the function that will execute whenever the event is triggered.
Fix:
local text = script.Parent.Parent.TextLabel local function OnOver() text.Text = "random text" end local function OffOver() text.Text = "random text2" end -- Calling the "connect" method on the events, and passing the function as the argument. script.Parent.MouseEnter:connect(OnOver) script.Parent.MouseLeave:connect(OffOver)
Hope this helped.