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

How to make this zombie script?

Asked by
22To 70
9 years ago

So I made this zombie but I want the zombie to give a currency wihich is heads when it dies

my lame attempt..I also placed it in the zombie model

local Humanoid = script.Parent.Zombie -- Or Builder Or Whatever 
function 
Humaniod.Health = 0

Leaderstats.Change.Heads(10)

1 answer

Log in to vote
1
Answered by 9 years ago

There are many errors in this script; I take it you are new to scripting. I'll do what I can to help.

First off, you need a name and parameters for your function. Names can be any string of letters, but the parameters will always be (). It'll look something like this:

function died()

I'm assuming that you are checking if the Zombie's health reaches 0, not actually making the health = 0, which is what you're doing at line 3. You can just get rid of that whole line.

Now, the leaderstats. This is a tricky one. There is no way to get the player (which is the parent of leaderstats) in this type of script. You'll have to assign the stats inside the weapon the player kills the zombie with.

Fourth, you'll always have to end a function with literally "end." Here's how it'll look:

function died()
end

Then, we need something to fire that function. Using an event that fires the function when the health changes should be good. Here's how it'll look:

function died()
end

script.Parent.Zombie.Changed:connect(died) 

At the end of it all, the script is pretty much useless inside the zombie. You'll have to put it inside the weapon...

0
yea but how can i put it into the weapon? i dont know how to do that 22To 70 — 9y
Ad

Answer this question