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 7 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:

01print("Cash Leaderboard Loaded")
02 
03 
04function onPlayerEntered(newPlayer)
05 
06    local stats = Instance.new("IntValue")
07    stats.Name = "leaderstats"
08 
09    local cash = Instance.new("IntValue")
10    cash.Name = "Cash"
11    cash.Value =  50
12    cash.Parent = stats
13    stats.Parent = newPlayer
14end
15 
16 
17 
18game.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 — 7y

1 answer

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

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

1if script.Parent.Health == 0 then
2value = 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