Need help on damage indicators

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I need the damage indicator to add up damage, and disappear after a short period.
    Ex: Each hit deals 10 damage, 1 hit it will show “10 damage” 2 hit it will show “20 damage”

  2. What is the issue? Include screenshots / videos if possible!
    Video
    also I used this topic to make it

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have no idea how to make it, If I use wait(time) then it will just glitch out.

This is where it shows the damage.

function Customize(element, number, numericType)
	local displayingNumber = ceil(number)

	if numericType == "-0" or numericType == "-2" then --// Damage dealt
		element.TextColor3 = color1
	elseif numericType == "-1" or numericType == "-3" then --// Critical damage
		element.TextColor3 = color3
	elseif numericType == "-4" then --// Damage received
		element.TextColor3 = color2
	elseif numericType == "+0" then --// HP restored
		displayingNumber = "+" .. displayingNumber
		element.TextColor3 = color4
	else --// Neutral
		element.TextColor3 = color5      
	end
	element.Text = tostr(displayingNumber.." Damage")	
	--//Display number on shadow text.
	element.Shadow.Text = element.Text
end

You need a way to track combos (certain number of hits performed in a short time span) that way instead of displaying 10 for each hit if 2 hits are recorded in quick succession you can first display 10 as expected and then 20.

Does this code have any errors?

Nope it doesn’t have any errors.

I don’t really get it, how do I track combos?

I assume you mean similar to how TF2 handles it? How I might go about this’s to create the BillboardGUI, have its Visible property be false, and have a script in it that listens for when an IntValue changes. The IntValue would be added to and reset back to 0 after X amount of seconds from the last change. The script within the BillboardGUI would check if the number was 0, and if it was hide it again, otherwise make it visible and display the damage.

Is there a way to make a countdown because wait() breaks the script

also this is the current script after editing

function Customize(element, number, numericType)
	local displayingNumber = ceil(number)
	if numericType == "-0" or numericType == "-2" then --// Damage dealt
		element.TextColor3 = color1
	elseif numericType == "-1" or numericType == "-3" then --// Critical damage
		element.TextColor3 = color3
	elseif numericType == "-4" then --// Damage received
		element.TextColor3 = color2
	elseif numericType == "+0" then --// HP restored
		displayingNumber = "+" .. displayingNumber
		element.TextColor3 = color4
	else --// Neutral
		element.TextColor3 = color5      
	end
	if element.Damage.Value ~= 0 then
		element.Damage.Value = element.Damage.Value + displayingNumber
		element.Text = tostr(element.Damage.Value.." Damage")
	else
		element.Damage.Value = displayingNumber
		element.Text = tostr(displayingNumber.." Damage")
		element.Shadow.Text = element.Text
	end
end

works fine but I just need a countdown to set the Gui’s visible to false

That should be fairly simple – you could have a variable assigned to a number, and subtract from the number. Once the number is less than or equal to 0, hide the GUI.

local TotalDisplayTime = 0 -- Indicator of how long to show the gui for
local DamageIndicator = path_to_int_value -- Self-explanatory

DamageIndicator.Changed:Connect(function(DamageNum) -- Listen for when the damage indicator's value changes, and see what number was passed
    if DamageNum > 0 then -- Was more than 0 damage dealt?
        TotalDisplayTime = 10 -- Set the variable to 10, the amount of seconds to display for. When the damage indicator is changed, the variable will be set to 10 again.
    end
end)

RunService.Stepped:Connect(function(_, Step) -- Get the step passed by Stepped
    if TotalDisplayTime > 0 then -- Is the time greater than 0?
        TotalDisplayTime -= Step -- Subtract from the time
    else -- Otherwise
        -- Hide the gui now
    end
end)

It isn’t as complicated as it looks. This simply changes TotalDisplayTime to 10 if the DamageNum – passed by DamageIndicator – was greater than 0. Then, in the function that Stepped calls every, well, step, it subtracts from the total time by how long it took for the step. Then, when the total time is 0 or less, it hides the GUI.

it worked! Thank you for taking the time.

1 Like