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

Is this the right way to do function onDeath()?

RealMoney = currency This is a script for when the zombie dies

function onDeath() 
	local player = game.Players
    player.leaderstats.RealMoney.Value = player.leaderstats.RealMoney.Value + 10000
end

1 answer

✓ Accepted answer

No, there are a few problems in your script.

  1. You are trying to modify the leaderstats of Players as in game.Players
  2. You currently don't have a way to get the player who killed the zombie so the game doesn't know who actually killed it
  3. All you are currently doing is defining a function, you need to connect it to a RBXScriptSignal like this https://developer.roblox.com/en-us/api-reference/event/Humanoid/Died if you want it to be executed when the zombie dies

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