01 | local Humanoid = script.Parent.Humanoid |
02 | function 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 |
14 | end |
15 | Humanoid.Died:connect(PwntX_X) |
theres no error in output (atleast of what i saw). My leaderstats name is the same, so is coins.
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.
01 | local type = "Coins" |
02 |
03 | bot = script.Parent |
04 | human = bot.Humanoid |
05 |
06 | cash = 10 |
07 |
08 |
09 |
10 | function 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 |
18 | end |
19 |
20 | script.Parent.Humanoid.Died:connect(onDied) |