I’m trying to detect the player being added so i can use .CharacterAdded to get the humanoid and then use Humanoid.Died so the player cant use a tool after they die. .PlayerAdded isn’t working in-game or in studio.
This script is located inside of a sword tool.
My script isn’t a localscript its a server script.
Keep in mind that since the playeradded event is in the tool, the event will be created AFTER the player joins the game which means the event wont run when the player holding the tool joins the game, only everyone after them.
Is this what you want?
What you could do instead of having the tool in the StarterPack is give the player the tool (by putting the tool in their character) whenever you want them to have it (i.e when a round starts) that way they won’t have the tool again when they die.
Try looping through each player and calling it. Sometimes the player loads before the event signal connects.
local function OnCharacterAdded(character)
local humanoid = character:FindFirstChild("Humanoid")
alive = false
local function OnPlayerAdded(player)
for _, player in pairs(game.Players:GetPlayers()) do
The script is most likely not running before the PlayerAdded event is firing, and therefore, the event listener has not been created at the time that the event is being fired. You’ll most likely have to reconsider your approach here. You can’t use PlayerAdded to obtain a reference to a player through a script that is created for that player after they join.