so i just followed a tutorial on damage indicators. i won’t lie, since i’m new to that topic.
this specific tutorial i followed worked great! it’s just i didn’t like how it spammed the damage indication…
there’s no errors, i’m just wondering how should i add a way to stop this from happening?
so sorry if it’s a waste of your time.
here’s a video of what happens:
https://i.gyazo.com/6d0013cbc483c64ff3a7941f8cce6785.mp4
the script which is in serverscriptservice
local tweenservice = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(0.3, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
local damageforcolors =
{
[25] = Color3.fromRGB(255,196,101),
[50] = Color3.fromRGB(255,234,0),
[75] = Color3.fromRGB(255,140,0),
[100] = Color3.fromRGB(255,0,0)
}
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local humanoid = char:WaitForChild("Humanoid")
local currenthealth = humanoid.Health
humanoid.HealthChanged:Connect(function(health)
if health < currenthealth and humanoid:GetState() ~= Enum.HumanoidStateType.Dead then
local healthlost = math.floor(currenthealth - health)
local damageindicatorgui = Instance.new("BillboardGui")
damageindicatorgui.AlwaysOnTop = true
damageindicatorgui.Size = UDim2.new(1.5,0,1.5,0)
local offsetX = math.random(-10,10)/10
local offsetY = math.random(-10,10)/10
local offsetZ = math.random(-10,10)/10
damageindicatorgui.StudsOffset = Vector3.new(offsetX,offsetY,offsetZ)
local damageindicatorlabel = Instance.new("TextLabel")
damageindicatorlabel.AnchorPoint = Vector2.new(0.5,0.5)
damageindicatorlabel.Position = UDim2.new(0.5,0,0.5,0)
damageindicatorlabel.TextScaled = true
damageindicatorlabel.BackgroundTransparency = 1
damageindicatorlabel.Font = Enum.Font.Arcade
damageindicatorlabel.Text = healthlost
damageindicatorlabel.Size = UDim2.new(0,0,0,0)
for damage, color in pairs(damageforcolors) do
if healthlost <= damage then
damageindicatorlabel.TextColor3 = color
damage = 100
end
end
damageindicatorlabel.Parent = damageindicatorgui
damageindicatorgui.Parent = char.HumanoidRootPart
damageindicatorlabel:TweenSize(UDim2.new(1,0,1,0), "InOut", "Quint", 0.3)
wait(0.3)
local guiuptween = tweenservice:Create(damageindicatorgui, tweeninfo, {StudsOffset = damageindicatorgui.StudsOffset + Vector3.new(0,1,0)})
local textfadetween = tweenservice:Create(damageindicatorlabel, tweeninfo, {TextTransparency = 1})
guiuptween:Play()
textfadetween:Play()
game:GetService("Debris"):AddItem(damageindicatorgui,0.3)
end
currenthealth = humanoid.Health
end)
end)
end)
thanks for your time! much appreciated!