How do i make this damage indicator a single instead of multiple?

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!

Your code is firing every time the characters health changes meaning it’s creating a new indicator each change. If you don’t want it to be so cluttered I recommend after 1 hit you then take into count every hit after and once hits have stopped you add them all up and display it as one indicator. For example:

Character gets hit… (5 Damage)
Hit again (5 Damage)
Hit again (5 Damage)
Doesn’t get hit for 0.5 seconds
Displays 15 Damage overall

Lets say you had a table setup to take into a count damage, assuming it is setup after the player joins the game you should be able to do something like so:

Also you can make a variable to store Damage[Player.Name] for ease of use.

local Hit = {
	["50Alpha"] = 0
}

Humanoid.HealthChanged:Connect(function(Health)
	if Hit[Player.Name] == 0 then --Hasnt been hit for the last 0.5 seconds
		local LastHealth = Humanoid.Health
		while wait(0.5) do --Check every 0.5 seconds if their health has changed
			if Humanoid.Health < LastHealth then --Check if they have been hit again
				break --If they have been hit break the loop
			end
			LastHealth = Humanoid.Health --Update last health
		end
		print(Hit[Player.Name]) --Print overall damage
		Hit[Player.Name] = 0 --Reset their hits
	else --Has been hit in the last 0.5 seconds
		Hit[Player.Name] += 5 --Add damage to their table
	end
end)

I think it’s because the sword spams the damage (assuming this is just the default roblox linked sword), I believe its just a .Touched event for the damage part of the sword without any debounce (basically a cooldown), so if you don’t add a debounce it’ll do that