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

Random Team Separating script no working?

The purpose of this script is to divide people evenly across 3 teams.
My Problem When ever trying to use this script it causes nothing to happen, and with no errors what so ever.

RequiredPlayers = 3
Teams={"VIP", "Guards", "Assasin"}

while true do
	player = game.Players:GetChildren()
	wait(1)
	if #player >= RequiredPlayers then
		Assign()
		break
	end
end

function Assign()
	local players = game.Players:GetChildren()
	for i = 1,#players do
		local ChosenTeam = Teams[math.random(1,#Teams)]
		
		players[i].TeamColor = game.Teams:FindFirstChild(ChosenTeam).TeamColor
		print("Teams Assigned")
	end
end

Thanks

2 comments

0

There's nothing wrong with the script that I can see. Ensure that the script actually executes, and that you are attempting with at least 3 test players. Make sure you actually have those teams in game.Teams

0

For some reason the script doesnt seem to be executing?

2 answers

Does it execute in studio mode? Or is it in play mode? IF it's in play mode press F9 and see what error you get

You put the infinite loop before the function itself means the script will never read it. Put the function before the infinite loop

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