How to increase the damage of a single player

Hello, I’m trying to increase the damage of a single player, but because I stored a damage variable in a server script, it ends up increasing the damage for every player. How can I make it so that only one player’s damage is increased?

If you are wanting to get or set the health of a current player, just change the Health value under the player’s humanoid, like this.

local character = player.Character
local humanoid = character:WaitForChild('Humanoid')

humanoid.Health = 50 -- This is how much health the player has. 100 is full, 0 is dead

I hope this is what you are looking for! Good luck :slight_smile:

make a table to keep track of players’ damage

local damage = {}

game.Players.PlayerAdded:Connect(function(player)
	damage[player.Name] = 0
end)

--some sorta function or something would go here
damage[player.Name] += 25897689547654 --(any number you want)

Thanks, how do I make it so that the table saves across scripts with the same code below?

You could use a ModuleScript and store damage values within it and require it from whatever scripts you need to reference it.

You can use attributes set to the character, although when the character dies it will loose it.

Like Chad said, you could use a ModuleScript, or like what shadowcrafter2017 said you could use attributes. These two would make the most sense if you are trying to store a player’s damage in a single session.

If you want to save the player’s damage for when they rejoin, you would have to use a DataStore.