local PlrHitTable = {
}
local Plr1 = nil --example
local Plr2 = nil -- example
local Plr3 = nil -- exmple
local function AGotHitByB(A, B)
PlrHitTable[A] = B
end
local function CharSetup(Plr)
PlrHitTable[Plr] = nil
Plr.Character.Humanoid.Died:Once(function()
if PlrHitTable[Plr] ~= nil then
local MyKiller = PlrHitTable[Plr]
--Reward The Killer
end
end)
end
game:GetService("Players").PlayerAdded:Connect(function(Plr)
repeat task.wait() until Plr.Character
CharSetup(Plr)
Plr.CharacterAdded:Connect(function()
CharSetup(Plr)
end)
end)
--Example A got hit by B
AGotHitByB(Plr1, Plr2)
i want to give the player money when killed an npc. i made a script so now i can see who killed the npc but i cant give the player money. the script i used is:
local Players = game:GetService("Players");
script.Parent.Humanoid.Died:Connect(function()
local playerWhoKilled = script.Parent.Humanoid:WaitForChild("creator").value
print(playerWhoKilled)
Players:FindFirstChild(playerWhoKilled).data.Cash.Value += math.random(70,120)
end)