Hi, it all depends what kind of damage you want to display, but let’s say it’s the player’s character, when they change health.
Player.CharacterAdded:Connect(functio(Character)
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.HealthChanged:Connect(function()
HealthTextLabel.Health = Humanoid.Health -- When the health changes
end)
HealthTextLabel.Health = Humanoid.Health -- When they spawn in
end)
Yeah like if the amount was 545 or 546m ect, it would then show the amount but then if none was done it would then return to 0 i could script it to show the value but would only show it and if it increased
I am assuming you wanna get the amount of damage dealt on an NPC or another player.
You could get the original health of the other npc/player and then subtract it by its current health, something like this:
local originalHealth = Humanoid.Health -- this is the value of the original health of the player or npc
local textToDisplay = gui.TextLabel -- where you wanna display the damage output
Humanoid:GetPropertyChangedSignal("Health"):Connect(function() -- detects if the health has changed
textToDisplay.Text = originalHealth - Humanoid.Health
end)
This is a rough script, but hopefully it can help you a little.
Nico sent you a good bit of guidance on what you can do. But if you want the attacker to see how much damage they’ve done, you just fire a remote to their client, at the same spot in your code where you deal the damage to the target.
No no i was meaning for the player to be shown the output on there screen so they can see the amount of damage they are doing to like a npc and like per second so if i did 5 damage per hit and it took 1 second to do the damage it would show 5, or if it was 2 hits in the 1 second it would show 10, but im gonna have a look at what nico was explaining
That is the same deal. In the weapon-script or whatever script you deal damage with, fire a remote to the player, telling them how much damage they did. You can find the Player in multiple ways, either by their character directly, or from the .Parent of the weapon ect.
Do you mean that you want it to show the DPS, and not only the damage? (Damage per second)
In the Script below you will be able to see the value of your health when you spawn in and also when you change your health.
To explain the script, it waits for the Humanoid to be spawned in then it checks if the Health has changed and if it has, it updates the HealthTextLabel.Text to the current Health amount.