local Players = game:GetService("Players") function OnPlayerAdded(player) print (player.Name .. " has entered the game") local Humanoid = game.Players.Parent:findFirstChild("Humanoid") local torso = Humanoid.Parent.Torso Players.PlayerAdded:connect(OnPlayerAdded) -- etc.... The script continues but it's unnecessary information.
Also, i want to get the Humanoid from the Player, but i'm really struggling on how to get the correct syntax on finding the Humanoid.
But the main problem is the OnPlyaerAdded Event, it doesn't fire, it doesn't do the print.
You're not checking if Player's Character have humanoid but instead you're checking if games has Humanoid.
local Players = game:GetService("Players") function OnPlayerAdded(player) print (player.Name .. " has entered the game") local Humanoid = player.Character:findFirstChild("Humanoid") if Humanoid then--You aren't checking if Humanoid is actually there if it isn't your script will error. local torso = Humanoid.Parent.Torso --Code end Players.PlayerAdded:connect(OnPlayerAdded)
~UserOnly20Charcters, Hoped I helped you to answer your question! If you have any further question, don't hesitate to comment below!!
~UserOnly20Charcters, it gives me this error:
Even setting it as player.Parent, so when someone joins it gets the parent of it so it identifies the character it still doesnt....
You should wait for the player's character to load, so you should add the line below under the print
.
repeat wait() until player.Character
This line checks if the player's character has loaded yet, if it has; it runs the rest of the code, if it hasn't; it will just keep repeating itself.
(Thanks to UserOnly20Characters for the original code below)
local Players = game:GetService("Players") function OnPlayerAdded(player) print (player.Name .. " has entered the game") local Humanoid = player.Character:findFirstChild("Humanoid") if Humanoid then local torso = Humanoid.Parent.Torso end end Players.PlayerAdded:connect(OnPlayerAdded)
Reference: http://wiki.roblox.com/index.php?title=Loops#Repeat