When I added a small function to my script to check if the Mouse's target was an object, it started giving me an error: Attempt to connect failed: Passed value is not a function at line 4.
script.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() if mouse.Target == nil then else mouse.Button1Down:connect(Check) end function Check() --the rest of script goes down here. It's been working fine.
I'm not sure what it means that the value is not a function. I have a guess that it might have to do with me use mouse.Button1Down
twice, but I'm not sure (also, I didn't know what other Event to put there).
You made a little confusion.
script.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() if mouse.Target == nil then else mouse.Button1Down:connect(Check) -- You shoulden't be calling it by event. You can't force the MOUSE to connect it. end function Check() -- make this come first :P --the rest of script goes down here. It's been working fine.
The ATTEMP TO CONNECT FAILED means it couldn't connect to function since the EVENT returns false and not true like it should return.
Let's take a look at Events: They are read-only, wich means you cant edit them. You can only read them and use them, but you can't edit them. In this case, you tried to edit an event.
Just replace the 'mouse.Button1Down:connect(Check)' with 'Check()'.
You could also change the 'if mouse.Target == nil then', that part you make the code 'NIL' inside statement. You could just replace to 'if mouse.Target ~= nil then', wich means it isn't 'NIL'.
function Check() -- idk wats ur code for this end script.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() if mouse.Target ~= nil then Check() else return end
Hope this helps! If it doesn't, tell me what appears on output. Thanks, marcoantoniosantos3