I’m making an assist system where when you hit an npc you get a percentage of the full reward if you killed it by yourself. Say an npc had 100 health and i did 50 damage to it, i would get 50% of the reward.
This is my script as of now:
local Reward = 25
local Players = {{“p_pof”,80},{“p_pof”,20}} – Table with players who did damage
local function RewardingPlayer()
for _, PlayerTable in pairs(Players) do
print(PlayerTable)
local Player = game.Players[PlayerTable[1]] -- Getting player
--if PlayerTable[2] < Humanoid.MaxHealth then
local PlayerDamage = PlayerTable[2]/Humanoid.MaxHealth
local PlayerReward = Reward * PlayerDamage
print(Player)
Player.leaderstats.Nooblets.Value = Player.leaderstats.Nooblets.Value + PlayerReward
game.ServerScriptService.NoobletsScript.Add:Invoke(Player, PlayerReward)
--end
end
end
Humanoid.HealthChanged:Connect(function()
local tag = Humanoid:findFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
end
end
end)
My problem is that I’m not sure how to insert a table with the player’s name and the amount of damage they’ve done. Any help on this would be appreciated. I’m also wondering if this script could be improved.
thanks!