How to provide player cash when killed using sword?

Sup! I am trying to make a sword that gives cash when you defeat an enemy, but I don’t know how to.

I have made a folder containing a script in ServerscriptService:

game.Players.PlayerAdded:Connect(function(plr)

	local leaderstats = Instance.new("Folder", plr)
	leaderstats.Name = "leaderstats"

	local Cash = Instance.new("IntValue", leaderstats) -- Create a score variable
	Cash.Name = "Cash" -- Name
	Cash.Value = 150 -- Initial Value
	game.StarterGui.BasicUI.Money.Text = Cash.Value .. "$"
end)

now how do i accomplish this??

When sword damages someone, make a objectvalue with value Player, if humanoid dies, give money to objectvalue.Value

what should the parent of that value be?

enemy’s humanoid

in the sword script, make it add to the cash value after it damages. thats how i would do it, probably better ways out there

Thanks for the suggestions! i will try them

how do i know if i damaged the enemy?

1 Like