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

How do I check If changed is changed to red team?

local player = game.Players.LocalPlayer

player.Changed:Connect(function(changed)
	if changed == "TeamColor" then
	    
				-- how do I check if it changed to red team
	
		Print("team Changed to red")
	end
end)

3 comments

0

Please put all your code inside of code blocks

0

I did ut I dont know how to check if it changed to red team

0

if (player.TeamColor = BrickColor.new("Really red")) then ... end

1 answer

✓ Accepted answer

Following your code you'd do it this way:

local player = game.Players.LocalPlayer

player.Changed:Connect(function(changed)
    if changed == "TeamColor" then
        if player.TeamColor == BrickColor.new("Really red") then --replace with the BrickColor of the team
            print("team Changed to red")
        end
    end
end)

However I'd recommend checking for the actual team instead of its color, and using GetPropertyChangedSignal

local team = game:GetService("Teams"):FindFirstChild("Team Name Here")
player:GetPropertyChangedSignal("Team"):Connect(function()
    if player.Team == team then
        print("team changed to red")
    end
end)

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