Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this script not changing the players team?

Asked by 7 years ago
Edited 7 years ago
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.

0
You don't name teams, you change the color of the team BlackOrange3343 2676 — 7y

1 answer

Log in to vote
1
Answered by
gitrog 326 Moderation Voter
7 years ago

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

Ad

Answer this question