I've been trying to make this script. It's supposed to check if the player's deaths == 11 and then changes their team to Spectators, and respawns them.
player = game.Players:WaitForChild("LocalPlayer") if player.leaderstats.deaths.Value == 11 then player.TeamColor = BrickColor.new("White") player:LoadCharacter() end
LocalPlayer
is a property, not a child, of Players
. You cannot WaitForChild
it, because there is no "LocalPlayer" child.
In addition, you never need to wait for LocalPlayer
.
player = game.Players.LocalPlayer
In addition to what BlueTaslem said, you only run the script/function once. You need to continually wait until the Player's deaths become equal to 11. This would work:
local player = game.Players.LocalPlayer function checkDeaths() if player.leaderstats.deaths.Value == 11 then player.TeamColor = game.Teams.Lobby.TeamColor player:BreakJoints() end end player.leaderstats.deaths.Changed:connect(checkDeaths) --This runs the function every time the player's death value changes. Alternatively, you can use "player.Died:connect(checkDeaths)", although I suggest the original.