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

can someone help me with this player changing teams by random script?

Asked by 4 years ago
Edited 4 years ago

I have this script where every 60 seconds the player will change teams randomly. i put the script in workspace and it isnt working! so can someone please help me with this?

this is the code:

local player = game.Players.LocalPlayer
local TeamValue = 0

while true do
    wait(60)
    TeamValue = math.random(1, 2)
    if TeamValue == 1 then
        player.Team = "Red Team"
    end
    if TeamValue == 2 then
        player.Team = "Blue Team"
    end
end

1 answer

Log in to vote
0
Answered by 4 years ago
--// Variables
local Teams = game.Teams:GetChildren()

while wait(60) do
    for i,v in pairs(game.Players:GetPlayers()) do
        local RandomTeam = Teams[math.random(1, #Teams)]
        v.Team = RandomTeam
    end
end
0
Thanks for the help! TheHuangBrothers -3 — 4y
Ad

Answer this question