while wait() do local Players = game.Players:GetPlayers() local MonsterKing = Players[math.random(1, #Players)] if MonsterKing.name == not game.ServerStorage.LastMonsterKing.Value then game.Players[MonsterKing.name].Team = game.Teams["Monster King"] game.ServerStorage.LastMonsterKing.Value = MonsterKing.name break end end
I'm trying to make it so that my game will randomly choose a player to be the monster king while making it so they were not the monster king last time.
This should work.
while wait() do local Players = game.Players:GetPlayers() local MonsterKing = Players[math.random(1, #Players)] if MonsterKing.name == not game.ServerStorage.LastMonsterKing.Value then game.Players[MonsterKing.name].TeamColor = game.Teams["Monster King"].TeamColor game.ServerStorage.LastMonsterKing.Value = MonsterKing.name break end end