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

I need help scripting a kill NPC for cash script?

Asked by 6 years ago

I am trying to make a zombie game for me and my friends to play but I don't know how to make it so you gain cash for each kill. I want it to be different for each different zombie.

Info: The currency is "Cash" Here is also the leaderboard script:

print("Cash Leaderboard Loaded")


function onPlayerEntered(newPlayer)

    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"

    local cash = Instance.new("IntValue")
    cash.Name = "Cash"
    cash.Value =  50
    cash.Parent = stats
    stats.Parent = newPlayer
end



game.Players.ChildAdded:connect(onPlayerEntered)

Thank you to anyone that helps

0
You need to keep track of who killed the zombie ie who attacked last then find this player and give them the cash User#5423 17 — 6y

1 answer

Log in to vote
0
Answered by
PastDays 108
6 years ago

Put a script inside the zombies Humanoid with an if statement like:

if script.Parent.Health == 0 then
value = value +1

Every time you kill one the cash would increase, to make this work you'd have to increase the value of the "cash.Value" wherever that is stored.

0
it dosent work for me i put the scrip in zombies humanoid and the code i go test it dosent owrk mybae im dont something wrong ? egopego123 0 — 4y
Ad

Answer this question