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

Why does this give money on kill script not work on my zombie in workspace?

Asked by
Nozazxe 107
3 years ago
01local Humanoid = script.Parent.Humanoid
02function PwntX_X()
03    local tag = Humanoid:findFirstChild("creator")
04    if tag ~= nil then
05        if tag.Value ~= nil then
06            local Leaderstats = tag.Value:findFirstChild("leaderstats")
07            if Leaderstats ~= nil then
08                Leaderstats.Coins.Value = Leaderstats.Coins.Value + 10 --how much you get for killing the npc
09                wait(0.1)
10                script:remove()
11            end
12        end
13    end
14end
15Humanoid.Died:connect(PwntX_X)

theres no error in output (atleast of what i saw). My leaderstats name is the same, so is coins.

1 answer

Log in to vote
1
Answered by
Gogulsky 129
3 years ago

If the humanoid has "creator" value in it - delete it. If the noob icon inside of the enemy is named Humanoid - this should work. Put this as a script inside of the enemy model.

01local type = "Coins"
02 
03bot = script.Parent
04human = bot.Humanoid
05 
06cash = 10
07 
08 
09 
10function onDied()
11    local killer = human:findFirstChild("creator")
12    if killer~=nil then
13        local money = killer.Value.leaderstats:findFirstChild(type)
14        if money~= nil then
15            money.Value = money.Value + cash
16        end
17    end
18end
19 
20script.Parent.Humanoid.Died:connect(onDied)
Ad

Answer this question