Cash goes to player that died but not to the killer

So i made a script where it gives the player money if they kill somebody but the script is giving money to the player that died and not the person that killed the player: this is the script:

game.Players.PlayerAdded:connect(function(player)
	local leaderstats = Instance.new("Folder",player)
 	leaderstats.Name = "leaderstats"

 	local cash = Instance.new("IntValue",leaderstats)
 	cash.Name = "Money"
	cash.Value = 10
	
	player.CharacterAdded:Connect(function(Character)
		Character.Humanoid.Died:Connect(function(Died)
			local creator = Character.Humanoid:FindFirstChild("creator")
			local leaderstats = creator.Value:FindFirstChild("leaderstats")
			if creator ~= nil and creator.Value ~= nil then
				leaderstats.Money.Value = leaderstats.Money.Value + 35
			end
		end)
	end)
	
end)

Hello,

So looking at your script, it is giving setting the leaderstats variable to the player that dies as shown in the image below

You would have to put a value inside of the player which contains the player who killed them if you wanted to code it like this.

Alternatively, you could do it from the killer’s side.

Let me know how it goes!

2 Likes

How can I put the value inside the script? I didn’t understand.

Hello,

I would recommend, on the killing side where the weapon is giving damage, check if the player has died and if so, award cash.

nvm I understand now 30 (chars)

2 Likes