#ATTEMPT TO CONNECT FAILED: passed value is not a function

1 messages · Page 1 of 1 (latest)

steel bear
#

Bro someone help this is killing me

#

btw i can do the part of the script where its at

cobalt hemlock
#

@steel bear very common mistake,

--so luau differentiates between functions and function calls
function ExampleFunction()
  return "Banana"
end

ExampleFunction --a var referring to the function
ExampleFunction() -- a function call

--when connecting events it is important to mix these 2 up

Event:Connect(ExampleFunction) -- correctly connects event to a predeclared function
Event:Connect(function() --correctly connects event to a newly declared function

end)

Event:Connect(ExampleFunction()) --no, you passed a call, returning whatever the function returns (in this case, banana) and connected it to an event. The string "Banana" is not a function and it will thus error when trying to connect the event to said string
steel bear
#

@cobalt hemlock im doing playerAdded and ut wont work

cobalt hemlock
#

And I just explained why...

steel bear
#

cant just tell me whats wrong with it and i can show u

#

?

#

in dms

open steppe
steel bear
#

a snippet of it or the whole thing cuz its long

open steppe
#

The line where it says the error is

steel bear
#

alr theres 3

open steppe
#

A snipper around it

#

Snippet

steel bear
#

im on discord on a different device so holdo n

#

its

#

players.PlayerAdded:Connect(playerAdded)

#

and

#

for _, player: Player in players:GetPlayers ()do
playerAdded(player)

open steppe
#

Can you send me the playeradded script?