How do I make my Damage Indicator color the same color as the team the Player is in?
function Track(Humanoid)
local Last = Humanoid.Health
local function HealthChanged(Left)
if Left < Last then
local Part = Humanoid.Parent:FindFirstChildWhichIsA("BasePart")
if Part then
local EffectPart = Instance.new("Part",script)
EffectPart.Name = "Effect"
EffectPart.Size = Vector3.new(0, 0, 0)
EffectPart.CFrame = Part.CFrame + Vector3.new(math.random(-5,5),math.random(3,5),math.random(-5,5))
EffectPart.Anchored = true
EffectPart.CanCollide = false
EffectPart.Velocity = Vector3.new(0,50 * (game.Workspace.Gravity / 196.2),0)
EffectPart.Transparency = 1
local BillboardGui = Instance.new("BillboardGui")
BillboardGui.Size = UDim2.new(3, 0, 3, 0)
BillboardGui.Adornee = EffectPart
BillboardGui.AlwaysOnTop = true
local TextLabel = Instance.new("TextLabel")
TextLabel.BackgroundTransparency = 1
TextLabel.TextStrokeTransparency = 0.8
TextLabel.Size = UDim2.new(1, 0, 1, 0)
TextLabel.Text = math.floor(Last - Left)
local Color = Color3.new(1,0.4,0.15)
local Player = game.Players:GetPlayerFromCharacter(Humanoid.Parent)
local BodyColor = Humanoid.Parent:FindFirstChildWhichIsA("BodyColors")
local Torso = Humanoid.Parent:FindFirstChild("Torso") or Humanoid.Parent:FindFirstChild("UpperTorso")
if Player and not Player.Neutral then
Color = Player.TeamColor.Color
elseif BodyColor then
Color = BodyColor.TorsoColor3
elseif Torso and Torso:IsA("BasePart") then
Color = Torso.Color
end
TextLabel.TextColor3 = Color
TextLabel.TextScaled = false
TextLabel.Font = Enum.Font.SourceSans
TextLabel.Parent = BillboardGui
BillboardGui.Parent = EffectPart
Last = Left
if EffectPart then
EffectPart.Anchored = false
EffectPart.CanCollide = true
end
if EffectPart then
EffectPart:Destroy()
end
end
else
Last = Left
end
end
Humanoid.HealthChanged:connect(HealthChanged)
end
local D = game.Workspace:GetDescendants()
for i = 1,#D do
if D[i]:IsA("Humanoid") then
Track(D[i])
end
end
function Added(item)
if item:IsA("Humanoid") then
Track(item)
end
end
game.Workspace.DescendantAdded:connect(Added)

2 comments
Thank you.
welcome