Alright, so I am trying to write a script that detects when a player joins a team. In this case, the team is called 'Clocktower'. There is a NumberValue that I stuck in there so that when a player joins that team, it adds 1 to that value. Then it would initiate the bottom part of the script. Where once it detects that a player has joined that team, it would start the repeat function until there are no more people in that team. Then, it would set the health of a humanoid in workspace to 0. I am uncertain if I can use the PlayerAdded function for teams or if I am using it correctly at all. If there is an easier way to do this, please do no hesitate. Go easy on me, I am still a beginner level scripter and I am only just learning some of the more advanced 'keywords.'
game.Teams.Clocktower.PlayerAdded:connect(function(player) game.Teams.Clocktower.NumberValue.Value = game.Teams.Clocktower.NumberValue.Value + 1 end) game.Teams.Clocktower.PlayerRemoved:connect(function(player) game.Teams.Clocktower.NumberValue.Value = game.Teams.Clocktower.NumberValue.Value - 1 end) if game.Teams.Clocktower.NumberValue.Value == 1 then repeat wait(1) until game.Teams.Clocktower.NumberValue.Value == 0 if game.Teams.Clocktower.NumberValue.Value == 0 then game.Workspace.Humanoid.Health = 0 end end
You should use
player.TeamColor--But define player.
Because I don't think that a player goes into team folder when they join. But in ~~~~~~~~~~~~~~~~~ game.Players ~~~~~~~~~~~~~~~~~ Thats the purpose of player.TeamColor