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

Cash For Kill Script Only Rewarding First Time?

Asked by 3 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":

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)

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 jordysboy 53 — 3y
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. horacioMiquen 15 — 3y
0
If possible could you post an example script? I’m fairly new to scripting. Snowmistx 0 — 3y

Answer this question