I need it so If a player kills another player the player that killed this player would gain, lets say 25 hp.
I have only a little bit of clue on how to do this. I really need help, its a key part in my game. I am only a mediocre scripter and don’t know how to do this.
I’ve searched for this for a while and I only found one response which didn’t make much sense to me, I need some help desperately lol.
there are various ways to do that, let’s do the simple one :
If you have a leaderstats, add this inside the leaderstats [change stuff accordingly]
player.CharacterAdded:Connect(function(char)
char.Humanoid.Died:Connect(function(Died) --fires whenever the player dies
local creator = char.Humanoid:FindFirstChild("creator") --looking for who killed him
local leaderstats = creator.Value:FindFirstChild("leaderstats")
if creator~=nil and creator.Value ~= nil then
game.Workspace:FindFirstChild(creator).Humanoid.MaxHealth += 20
game.Workspace:FindFirstChild(creator).Humanoid.Health += 20
end
end)
end)
There are multiple approaches for this particular problem. If your game uses RemoteEvents to register damage, use them to add HP to the player’s humanoid right after dealing damage to the target.
Bare in mind the marked solution will only work with weapons that create an ObjectValue instance inside the damaged player’s humanoid instance, where its value points/refers to the damaging player.