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

How do I make my Damage Indicator color the same color as the team the Player is in?

Asked by 2 years ago
Edited 2 years ago

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)

1 answer

Log in to vote
1
Answered by
Xyternal 247 Moderation Voter
2 years ago

So in the code I'm posting, in a team or not. You can modify the code to fit your needs

local teams = game:GetService("Teams")
local function checkPlayerTeam(player)
    if player.Team == "YouTeam" then
        print("You are in this team")
    else
        print("you are not in new team")
    end
end

game.Players.PlayerAdded:Connect(checkPlayerTeam)
0
Thank you. robloxtitanic584 92 — 2y
0
welcome Xyternal 247 — 2y
Ad

Answer this question