0

# How to give Cash when I killed an actual player?

I have a script within my NPC that correctly gives cash to the player when the player kills the NPC. I had to insert a script within the NPC to call a remote event, but I'm not quite sure how to do that with an actual player. I need to give 10 cash when a player kills another player. What am I doing wrong here? (FYI this is inside my save data, hence the other stuff in there.)

Look at lines 25-32. That is where I am checking if the player died to give money to whoever killed them.

local function onPlayerAdded(player)
local playerKey = "Player_" .. player.UserId
wait()
print("User ".. player.UserId.. " Joined")

local Cash = Instance.new("IntValue")
Cash.Name = "Cash"

local myCash
local success, err = pcall(function()
myCash = CashStore:GetAsync(playerKey) or STARTING_CASH
end)
if success then
Cash.Value = myCash
else
print("failed to retrieve data")
warn(err)
end

Character.Humanoid.Died:Connect(function(Died)
local creator = Character.Humanoid:FindFirstChild("creator")
if creator ~= nil and creator.Value ~= nil then
end
end)
end)

game.ServerStorage.Give.Event:Connect(function(Amount)
wait()
Cash.Value = Cash.Value + Amount
end)

end