Changing team mid game

  1. What do you want to achieve? Keep it simple and clear!
    i want to make a team detecting script which will give the colors of that team to the player

  2. What is the issue? Include screenshots / videos if possible!
    it doesn’t work if team doesn’t have auto assignable enabled

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i did look, but nothing

local teams = game:GetService('Teams')
local char = script.Parent
local player = game:GetService("Players"):GetPlayerFromCharacter(char)

if char and player.Team ~= nil then
	if player.Team == teams.Blue then
		local bodyColors = char:FindFirstChildOfClass("BodyColors")
		bodyColors.TorsoColor = player.TeamColor
		local hat = char:FindFirstChild("BrickHat")
		hat.Handle.BrickColor = player.TeamColor
	else

	end

	if player.Team == teams.Red then
		local bodyColors = char:FindFirstChildOfClass("BodyColors")
		bodyColors.TorsoColor = player.TeamColor
		local hat = char:FindFirstChild("BrickHat")
		hat.Handle.BrickColor = player.TeamColor
	else

	end
end

for some reason the script doesn’t work if any team doesn’t have the auto assignable option enabled (yes i did change the team of the player in-game)

note: the script is a server script, because i want the team color to appear to everyone