Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't my function work when someone joins (game.Players.PlayerAdded:connect(printall) )?

My code is this:

`function printall(stuff) print(stuff) print(stuff.Name) print(stuff.Character) end

--game.Players.PlayerAdded:connect(printall) local Players = game:GetService("Players") Players.PlayerAdded:connect(printall)`

It doesn't run the printall function?

3 comments

0

This should be working - check if your script is disabled. Also, if you're running this script after a player has joined, it wont register the function, so make sure thats not the case

0

Script not disabled, the actual function is declared before? It says 'nill' when printing the first time, then when printing stuff.Name errors out.

0

17:06:31.559 - ServerScriptService.Script:3: attempt to index local 'stuff' (a nil value) has appeared with it sooo

1 answer

✓ Accepted answer

You are pretty much doing game.Players.Players.PlayerAdded:Connect(printall) game.Players.PlayerAdded:Connect(printall) should work

Also, printall is a userdata, so you cannot print "stuff", you can print the properties of stuff though... character is also a userdata, so you need to do stuff.Character.Name

2 comments

0

Answer accepted, working. Thanks!

0

No problem bud :D

This discussion is preserved as it was. New answers, comments, and votes are closed.