Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Npc Cash For Kill Script Only Rewarding First Time?

Asked by 2 years ago

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". I have tried dozens of different cash scripts and tutorials, but so far this is the only script that even partly works. If someone could give insight with an example script that would be much appreciated given that I am very new to scripting.

01  game.Players.PlayerAdded:Connect(function(player)
02      local Zombie = script.Parent -- npc model
03      local Humanoid = Zombie.Humanoid -- humanoid inside the model
04      local Cash = player.leaderstats.Cash -- the money
05      local CashReward = 10 -- amount of money I want to give when npc dies
06      Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
07          if Humanoid.Health == 0 then
08              Cash.Value = Cash.Value + CashReward
09          end
10      end)
11  end)
0
Since you put it inside of the "PlayerAdded" function, it will only work once because the player is only added once. andarwniceguyjr 0 — 2y
0
ok i will try if i can Trorapantest1 13 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

https://www.youtube.com/watch?v=8PBy-YC6OeU

Ad

Answer this question