Making a Damage Indicator

Hello Developers, I need help on Something from my FPS game.

Does anybody know how to script a Working Damage Indicator?
I already watched Every Youtube Videos and followed it but nothing works

And even in DevForum.

It’s for a FPS game i’ve been working on

3 Likes

Are you looking for a directional damage indicator?

E.g.:

image

1 Like

Well not currently like that. Well it can be usefull, But the one like Arsenal have.

The one with Number Damage

2 Likes
local PS = game:GetService("Players")

local player = PS.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum: Humanoid = char:WaitForChild("Humanoid")
local oldHealth = hum.Health

hum.HealthChanged:Connect(function()
	local change = oldHealth - hum.Health -- this is the amount of damage taken
	oldHealth = hum.Health
	
	if change > oldHealth or change < 0 then
		return
	end
	
	warn(change)
end)

From this, you can probably incorporate this into your own code.

2 Likes

Hehehehe, About that. I do not know how to code like that. I’m still learning

1 Like

Put @Downrest’s code in a gui, and set a text label’s text the damage then make the damage go to 0 on the label after a second or something?

1 Like

I think we can do something like fire back to client of the player who attack with the damage and form that we add it to the gui, bc the damage number show in server it might seem messy

Have you tried following this tutorial?

The gist of the tutorial (and damage indicators in general):

  1. When a client does damage to a target, the server fires a remote event to that client with the target, damage dealt, and type of indicator to spawn
  2. The client receives the remote and creates the damage indicator with the damage dealt and correct style, places it on the target, then animates it with some tweening.

If you want to add the damage number batching that Arsenal has, in which multiple damage instances in a short timeframe are grouped into a single indicator:

  1. Create a dictionary that will store a target and its corresponding damage indicator object as a key-value pair
  2. When the client receives the event to create a damage indicator on a target, check if the target is in the dictionary
  3. If no, create a new indicator object and place the target and object in the dictionary. Also add a countdown (using coroutines or task.delay) after which you remove the indicator from the list.
  4. If yes, instead of creating a new indicator, instead add the damage dealt to the current indicator’s displaying number and display the sum.
  5. Reset any active fading, position, or size tweens and replay them. Also reset the countdown for removing the indicator (cancel the thread and start a new one).
2 Likes

It sounds like what you are looking for is an information display system. What @Downrest illustrated is a damage direction indicator which tells you what direction the damage came from.

@devloperblox You can’t display it in the server. It has to display on the client which means firing a remote event to the client with the damage number, and the position in the 3d world. From there you have to get the 2d screen coordinate and display it in a TextLabel at those coordinates.

@Content_Corrupted019 has the correct answer with the tutorial on how to make such a system.