Trouble with the Team Service (Neutral team bug)

Im currently having trouble with roblox’s team system. i have 1 Neutral team and 2 Round teams, when im assigning the players team sometimes the game will make a completely new Neutral team and assign players there.

This is what’s supposed to happen and what happens most of the time on studio.

This is what sometimes happens in studio, and what always happens when i play the published game.

Here’s my script

--//Round System Script

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

--Acquire Teams
local Neutral = teamService:FindFirstChild("Neutral")
local Alien = teamService:FindFirstChild("Alien")
local Agent = teamService:FindFirstChild("Agent")

-- Settings
local seekTime = 5
local hideTime = 5
local intermissionTime = 5

local function Countdown(duration)
	for i = duration, 1, -1 do
		print(i)
		task.wait(1)
	end
end

local function Intermission()
	print("Intermission")
	Countdown(intermissionTime)
end

local function HideTime()
	print("Hide!")
	Countdown(hideTime)
end

local function RoundOver()
	for i, plr in pairs(players:GetPlayers()) do
		plr.Team = Neutral
	end
end

local function SeekTime()
	print("Seek!")
	Countdown(seekTime)
end

local function Shuffle(plr)
	for i = #plr, 2, -1 do
		local j = math.random(i)
		plr[i], plr[j] = plr[j], plr[i]
	end
end

local function SetRoles()
	local playerList = players:GetPlayers()
	
	for i, player in ipairs(playerList) do
		if i <= 1 then
			player.Team = Alien
			print(player.Name.." set to "..player.Team.Name)
		else
			player.Team = Alien
		end
	end
	
end

while true do
	
	Intermission()
	SetRoles()
	HideTime()
	SeekTime()
	RoundOver()
	
end

--// Team Setup Script

local teamService = game:GetService("Teams")

--Teams
local Neutral = Instance.new("Team")
Neutral.Name = "Neutral"
Neutral.TeamColor = BrickColor.new(0.666667, 0.588235, 0.631373)
Neutral.Parent = teamService

local Agent = Instance.new("Team")
Agent.Name = "Agent"
Agent.TeamColor = BrickColor.new(0.380392, 0.411765, 0.545098)
Agent.Parent = teamService

local Alien = Instance.new("Team")
Alien.Name = "Alien"
Alien.TeamColor = BrickColor.new(0.219608, 0.666667, 0.258824)
Alien.Parent = teamService

1 Like

Set the Neutral team’s AutoAssignable to true and tell me the result

Unfortunately still the same result. heres is a photo from the published game.


heres is a photo from studio.

Additional photo with Neutral team renamed to Dead.

When you’re aquiring the teams, use WaitForChild instead of FindFirstChild. The teams may not be created yet. Also, why can’t you just create the teams in Studio?

I was just following the documentary so I honetly never thought of that haha. Also WaitForChild was a fix thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.