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 4 years ago
Edited 4 years ago
01local player = game.Players.LocalPlayer
02 
03player.Changed:Connect(function(changed)
04    if changed == "TeamColor" then
05 
06                -- how do I check if it changed to red team
07 
08        Print("team Changed to red")
09    end
10end)
0
Please put all your code inside of code blocks Cynical_Innovation 595 — 4y
0
I did ut I dont know how to check if it changed to red team Xx0966xX 41 — 4y
0
if (player.TeamColor = BrickColor.new("Really red")) then ... end Fifkee 2017 — 4y

1 answer

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

Following your code you'd do it this way:

1local player = game.Players.LocalPlayer
2 
3player.Changed:Connect(function(changed)
4    if changed == "TeamColor" then
5        if player.TeamColor == BrickColor.new("Really red") then --replace with the BrickColor of the team
6            print("team Changed to red")
7        end
8    end
9end)

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

1local team = game:GetService("Teams"):FindFirstChild("Team Name Here")
2player:GetPropertyChangedSignal("Team"):Connect(function()
3    if player.Team == team then
4        print("team changed to red")
5    end
6end)
Ad

Answer this question