Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
Edited 3 years ago
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)
0
Please put all your code inside of code blocks Cynical_Innovation 595 — 3y
0
I did ut I dont know how to check if it changed to red team Xx0966xX 41 — 3y
0
if (player.TeamColor = BrickColor.new("Really red")) then ... end Fifkee 2017 — 3y

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
3 years ago

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)
Ad

Answer this question