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

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

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

✓ Accepted answer
--// 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

1 comment

0

Thanks for the help!

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