Hello! So I'm having an issue with this npc cash for kill script. It is placed inside my npc (Zombie) and after a player kills it, they receive 10 cash. However, it stops rewarding the player cash after the first "10 cash":

game.Players.PlayerAdded:Connect(function(player)
	local Zombie = script.Parent -- npc model
	local Humanoid = Zombie.Humanoid -- humanoid inside the model
	local Cash = player.leaderstats.Cash -- the money
	local CashReward = 10 -- amount of money I want to give when npc dies
	Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
		if Humanoid.Health == 0 then
			Cash.Value = Cash.Value + CashReward
		end
	end)
end)

3 comments

0

Wheres the rest of the script? There should be more. Also why make a variable? You can just say Cash.Value = Cash.Value + 10

0

Try to create yourself a Value that for every kill the player makes on the zombie goes up by +1. As you have a variable that is worth +10 coins, make one for +0 and use If and Else to make it so that if <= 10 it activates the +10 coins variable, if >10 it activates the +0 one, and the player gets no reward.

0

If possible could you post an example script? I’m fairly new to scripting.