Idk why my damage indicator show 0 damage when i doing 0.7 damage

so this is my script is there anyway to fix it

local TS = game:GetService("TweenService")
local Tinfo = TweenInfo.new(0.3, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)

local DamageBoard = game.ReplicatedStorage.DamageBoard

local Red = Color3.fromRGB(255, 0, 0)
local Green = Color3.fromRGB(95,111,64)

for i, v in pairs(game.Workspace:GetChildren()) do
	if v:IsA("Model") then
		if v:FindFirstChildWhichIsA("Humanoid") then
			local hum = v:FindFirstChildWhichIsA("Humanoid")
			local humH = hum.Health
			
			hum.HealthChanged:Connect(function(Health)
				if Health < humH and Health > 0 then

					local Damage = math.floor(humH - Health)
					print(Damage.." Damage was taken")
					
					local BoardClone = DamageBoard:Clone()
					BoardClone:FindFirstChild("Damage").Damage = Damage

					local maxH = hum.MaxHealth
					BoardClone.Damage.TextColor3 = Green:lerp(Red, Damage / maxH)


					BoardClone.Parent = v.HumanoidRootPart
					
					BoardClone.Damage:TweenSize(UDim2.new(1,0,1,0), "InOut", "Quint", 0.3)

					wait(0.3)

					local UIupTween = TS:Create(BoardClone, Tinfo, {StudsOffset = BoardClone.StudsOffset + Vector3.new(0,1,0)})
					local textFade = TS:Create(BoardClone.Damage, Tinfo, {TextTransparency = 1})

					UIupTween:Play()
					textFade:Play()

					game:GetService("Debris"):AddItem(BoardClone, 0.5)
				end
				humH = hum.Health
			end)
		end
	end
end




This line, right here

local Damage = math.floor(humH - Health)

math.floor will always round your number to the lowest integer ( in this case 0.7 will always come out as 0), so if you change that line to

local Damage = (humH - Health)

then it will show the correct amount of damage

1 Like

umm now it show too many text , i just want it to show like 0.7 only

You can do something like this to round to nearest tenth:

local function roundNum(num) 
    return tonumber(string.format("%." .. (1 or 0) .. "f", num))
end

Could u show the number formed?

local DamageRaw = (humH - Health) 
local Damage = math.floor(DamageRaw * 10)/10 --0.7

image
now the number sometime stacked and sometime not

math.floor() rounds down. If you want it to show 1 then you should use math.ceil()

Because your taking 2 damage values in a very short period of time so they stack sometimes or dont stack

Damage =math.floor(Damage * 10 ^ 1)/10 ^ 1

@MadionChooi I edited it so tell me what output u get

For printing:

print(string.format("%.1f", Damage))

Also can you show your new script? because iā€™m pretty sure the method i posted only returns up to nearest tenth

is there a way to stack all damage as once

local TS = game:GetService("TweenService")
local Tinfo = TweenInfo.new(0.3, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)

local DamageBoard = game.ReplicatedStorage.DamageBoard

local Red = Color3.fromRGB(255, 0, 0)
local Green = Color3.fromRGB(95,111,64)

for i, v in pairs(game.Workspace:GetChildren()) do
	if v:IsA("Model") then
		if v:FindFirstChildWhichIsA("Humanoid") then
			local hum = v:FindFirstChildWhichIsA("Humanoid")
			local humH = hum.Health
			
			hum.HealthChanged:Connect(function(Health)
				if Health < humH and Health > 0 then
					
					local Damage = (humH - Health)
					print(Damage.." Damage was taken")
					
					local function roundNum(Damage) 
						return tonumber(string.format("%." .. (1 or 0) .. "f", Damage))
					end
					
					local BoardClone = DamageBoard:Clone()
					BoardClone:FindFirstChild("Damage").Text = roundNum(Damage)

					local maxH = hum.MaxHealth
					BoardClone.Damage.TextColor3 = Green:lerp(Red, Damage / maxH)


					BoardClone.Parent = v.Head
					
					BoardClone.Damage:TweenSize(UDim2.new(1,0,1,0), "InOut", "Quint", 0.15)

					local UIupTween = TS:Create(BoardClone, Tinfo, {StudsOffset = BoardClone.StudsOffset + Vector3.new(0,3,0)})
					local textFade = TS:Create(BoardClone.Damage, Tinfo, {TextTransparency = 1})

					UIupTween:Play()
					textFade:Play()

					game:GetService("Debris"):AddItem(BoardClone, 0.5)
				end
				humH = hum.Health
			end)
		end
	end
end




Only if your taking the exact same damage

local TS = game:GetService("TweenService")
local Tinfo = TweenInfo.new(0.3, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)

function roundNumber(num, numDecimalPlaces)
  return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
end

local DamageBoard = game.ReplicatedStorage.DamageBoard

local Red = Color3.fromRGB(255, 0, 0)
local Green = Color3.fromRGB(95,111,64)

for i, v in pairs(game.Workspace:GetChildren()) do
	if v:IsA("Model") then
		if v:FindFirstChildWhichIsA("Humanoid") then
			local hum = v:FindFirstChildWhichIsA("Humanoid")
			local humH = hum.Health
			
			hum.HealthChanged:Connect(function(Health)
				if Health < humH and Health > 0 then

					local Damage = roundNumber(humH-Health,1)
					print(Damage.." Damage was taken")
					
					local BoardClone = DamageBoard:Clone()
					BoardClone:FindFirstChild("Damage").Damage = Damage

					local maxH = hum.MaxHealth
					BoardClone.Damage.TextColor3 = Green:lerp(Red, Damage / maxH)


					BoardClone.Parent = v.HumanoidRootPart
					
					BoardClone.Damage:TweenSize(UDim2.new(1,0,1,0), "InOut", "Quint", 0.3)

					wait(0.3)

					local UIupTween = TS:Create(BoardClone, Tinfo, {StudsOffset = BoardClone.StudsOffset + Vector3.new(0,1,0)})
					local textFade = TS:Create(BoardClone.Damage, Tinfo, {TextTransparency = 1})

					UIupTween:Play()
					textFade:Play()

					game:GetService("Debris"):AddItem(BoardClone, 0.5)
				end
				humH = hum.Health
			end)
		end
	end
end