Healthbar not working correctly

Hello, I decided to make a healthbar on the server that doesn’t change the players actual health. I managed to make it work but the issue now is that the players are taking damage other players take which i don’t want. When the player takes damage it updates the ui so when another player takes alot of damage then that players ui will update until someone else takes damage and then they will take all the damage other players took.

server script:

this function is called when a player takes damage using Damaged(Hit.Parent, 5)

local function Damage(plr, dmg)
	local Humanoid = plr.Humanoid
	local player = game.Players:GetPlayerFromCharacter(Humanoid.Parent)
    DmgEvent:FireClient(plr, currentShield, currentHealth)

local script:

damageEvent.OnClientEvent:Connect(function(Armor, HP)
	Healthfillbar.Size = / 100, 0, 1, 0)
	healthtext.Text = HP
1 Like

Could you explain a little more? I’m not 100% sure what you’re trying to do.

im trying to make a healthbar on the server and just show values on the players screen instead of affecting their actual hp. the issue that im having is when one player takes damage the rest of the players on the server also take that same amount of damage.

Why did you choose to make the health bar be on the serverside? Is it just one health bar, or is it like a display above each player? I’m just trying to understand your goal.

i don’t know it was mainly for fun and to see what happens if i do. Its just a health and shield bar that doesn’t affect the players actual hp so i guess it can be used to prevent players from altering their hp.

From what I gather, I think your issue is a design issue. If you want a custom health bar, you should keep it in the player’s StarterGui and put all scripts in a LocalScript. I think what you’re trying to do is make an armor ‘health bar’, and if so, you should do so on the client side.

thats kind of unrelated to my issue though. I just have an issue of shared damage and i want to get rid of it.

Well, if the health bar is on the server and all the players are calling Damage on it, the only way to make it look differently for each player would be with a local script- going back to the issue of design. Generally, with user interface, you want to use a local script, since local scripts make changes for each player individually, thus avoiding the shared damage. If it’s on the server, there really is no good way of making one player take the damage. Server-side stuff is supposed to be for everyone, and clientside stuff is supposed to be for one player. Hopefully this makes sense.

nvm, I found the issue. I was being dumb and saving the hp to a variable

Glad you solved your issue. Sorry I couldn’t be more helpful. You should mark the post as solved when you get the chance.