Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is this script not changing the players team?

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.

1 comment

0

You don't name teams, you change the color of the team

1 answer

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.