The script below is supposed to occur when the player dies, putting them into a team. It doesn’t work at all. Why does this not work? What is the issue? Thanks in advance!
Keep in mind this is a script, not a local script.
local player = game:GetService("Players").PlayerAdded:Wait()
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local teams = game:GetService("Teams")
local playerobject = player.TeamColor
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
while true do
if humanoid.Health == 0 then
player.Team = teams["Players"]
character.Parent = workspace.PlayerWaitingFolder
end
wait(1)
end
end)
end)
tried it, also edited my script a little. didn’t work though
local player = game:GetService("Players").PlayerAdded:Wait()
local character = player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local teams = game:GetService("Teams")
local playerobject = player.TeamColor
game:GetService("Players").PlayerAdded:Connect(function(player)
humanoid.Died:Connect(function(character)
while true do
if humanoid.Health == 0 then
player.Team = teams["Players"]
character.Parent = workspace.PlayerWaitingFolder
end
wait(1)
end
end)
end)
local player = game:GetService("Players").PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local teams = game:GetService("Teams")
local playerobject = player.TeamColor
humanoid.Died:Connect(function(character)
player.Team = teams["Players"]
character.Parent = workspace.PlayerWaitingFolder
end)
not sure if this is exactly what you’re trying to do, but it should work
The parenting was supposed to be part of a system for counting (I have a timer that goes off, showing the number of children in that folder which are the players.) Thanks for the explanation on the PlayerAdded:Wait().