Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I need help scripting a kill NPC for cash script?

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

1 comment

0

You need to keep track of who killed the zombie ie who attacked last then find this player and give them the cash

1 answer

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.

1 comment

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 ?

This discussion is preserved as it was. New answers, comments, and votes are closed.