How do I use only players of one team in a script?
For example, the team name is "Fighters" and I want to use a function that teams anyone in that team back to Spectators if Fighters has one or less player. If one player then announce the winner, if 0 then announce a tie.
Fight = game.Workspace.Fight.Value GameVal = game.Workspace.GameVal.Value Fighters = game.Teams.Fighters:GetChildren() function finish() if GameVal == true and #Fighters == 1 then Fighter = Fighters.FindFirstChild.Name m = Instance.new("Hint") m.Parent = game.Workspace m.Text = Fighter.."has won the round!" GameVal = false wait(3) m:remove() elseif GameVal == true and #Fighters == 0 then m = Instance.new("Hint") m.Parent = game.Workspace m.Text = "There has been a tie!" wait(3) m:remove() end end Fight.Changed:connect(finish)
Will this work or how should I approach this?
Fight = game.Workspace.Fight.Value GameVal = game.Workspace.GameVal.Value Fighters = game.Teams.Fighters:GetChildren() function finish() Fighters = game.Teams.Fighters:GetChildren() --Re-Defining Fighters value if GameVal == true and #Fighters == 1 then Fighter = Fighters --Since there is only one player, it's getting all the children in Fighters, which is just that one player m = Instance.new("Hint") m.Parent = game.Workspace m.Text = Fighter.Name.." has won the round!" --Inserted a space, would have looked like this "Player1has won the round!", also you forgot to have it get the fighter's name, you were trying to get the fighter's player object GameVal = false wait(3) m:remove() elseif GameVal == true and #Fighters == 0 then m = Instance.new("Hint") m.Parent = game.Workspace m.Text = "There has been a tie!" wait(3) m:remove() end end Fight.Changed:connect(finish)
Try it and tell me how it works! :D