✓ Accepted answer
Line 9 is going crazy!
The best way I could suggest fixing this would be to redo line 9.
How to call functions,
Here's an example of calling a function that will print Hello World!.
local function Print()
print("Hello World!")
end
Print()
How to use events to call functions,
Here's an example of an event that will connect to a function that prints Hello World, like before, but it's now connected to an event.
local ClickDetect = script.Parent:WaitForChild("ClickDetector")
local function print()
print("Hello World!")
end
ClickDetect.MouseClick:connect(print)
The Above Will Print "Hello World!" When The Part Is Clicked
Your problem,
Your problem is that you're using function calls wrong. You also seem to think that the MouseEnter gives that button. This is false. Define your button before hand for less errors. Here's what your script should look like,
local button = script.Parent
function MouseEnter(mouse)
button.MouseLeave:connect(function()
doSomething()
end)
doSomething()
end
button.MouseEnter:connect(MouseEnter)
Or, optionally,
local button = script.Parent
button.MouseEnter :connect(function(mouse)
button.MouseLeave:connect(function()
doSomething()
end)
doSomething()
end
I moved the function calls for slight efficiency#####
I hope that works.
Good Luck!
1 comment
What the heck is line 9 doing?