Teams broken/bugged?

Ill keep this short
Basically either my script is broken or the Team system is bugged.

local players = game:GetService("Players")
local Team = game:GetService("Teams")

--Teams
local aa = Instance.new("Team", Team)
aa.Name = "1"
aa.AutoAssignable = true
local ab = Instance.new("Team", Team)
ab.Name = "2"
ab.AutoAssignable = true

local team_Select = {
	[1] = aa,
	[2] = ab
}

function randomplayer()
	local plrs = players:GetChildren()
	local do_math = math.random(1, #plrs)
	local team_math = math.random(1, #team_Select)
	for i, v in pairs(plrs) do
		if i == do_math then
			if workspace:FindFirstChild(v.Name) then			
				local team = players.LocalPlayer.Team.Team == team_math
			end
			break
		end		
	end
end

players.PlayerAdded:Connect(function(player)
	randomplayer()
end)

(when I refer to “aa” and “ab” I referring to the team variables.)

This script above simply creates teams and randomly puts the player in one of the teams. However only Team One (aa) is showed on the leaderboard. If I check explorer, both teams are there. If I remove the team I’m currently in (aa), then I will be in Team Two (ab).

Video below shows the issue :

Have you tried making the two teams have different team colors?

1 Like

Ill try that out and see what happens.

Wow it worked! I feel so dumb. Poses a new problem though, It’s only selecting Team 1.

Like the random thing? In short, the random function isn’t actually random because it depends on one thing. You need to supply a thing to make it random, using the function math.randomseed().

If you don’t do that, the random thing will of course keep you getting 1 as an answer. You need to think of something that constantly changes.

So, think about something that changes every time. Time! So you can set the random seed with the time. You can put in your script: math.randomseed(tick())

Hope that’s helpful!