Hello, I’m OriginalDevelops! I’m making a fighting game! In fighting game, the most important is the damage counter to player see what is their damage right? So today I’m having a question, how can I make a damage counter that similar to all players in the game? Their damage will be count and locked to that NPC or Player got damaged! Hope someone can help me with this.
To clarify, do you mean a health bar, or a damage indicator. By damage indicator I mean a number that appears telling you how much damage you did to someone.
Do you how much damage they’ve inflicted on someone? You should probably insert an intvalue and when they take damage, increase the intvalue by the amount of damage they have taken, if that’s what you mean. It’s kind of ambiguous though.
One way you can do it is all inside a server script, and search through everything with a humanoid. When the humanoid’s health changes, create a surface gui or something
Sadly I don’t but I can provide you with some pseudo code,
You’re obviously going to have to change most of it to how want it to work, but it should lead you to the right path.
(Inside your serverside damage script), ServerSide,
-- put this at the top of your script
local remote = Instance.new("RemoteEvent", game.ReplicatedStorage); remote.Name = "Remote";
-- put this inside your damage function
remote:FireClient(player, totalDamage, targetPlayer) -- total damage is your total damage dealt, target player is the player that's getting damaged
LocalScript,
-- // SERVICES
local Debris = game:GetService("Debris");
-- // VARIABLES
local remote = game.ReplicatedStorage:WaitForChild("Remote");
-- // FUNCTIONS
local function damageIndicator(player, totalDamage, targetPlayer)
if player.Head:FindFirstChild("DamageIndicator") then -- player already has a damage indication
--[[
Do what you want here you can update the curent text to the new damage or create a whole new indication on top of it
]]--
else -- player doesn't have an existing indicator
local newIndicator = Instance.new("BillboardGui", targetPlayer.Head); newIndicator.Name = "DamageIndicator";
local newIndicatorText = Instance.new("TextLabel", newIndicator); newIndicatorText.Text = totalDamage
-- you can change the gui properties as you want here.
Debris:AddItem(newIndicator, 2) -- this will remove the indicator after 2 seconds
end
end
-- // REMOTES
remote.OnClientEvent:Connect(damageIndicator)
Hope this helps if it does don’t forget to mark it as a solution!