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

Whats the error with this kill npc money script? y output isnt help at all with this.

Asked by 4 years ago
01local Humanoid = script.Parent.Humanoid
02function MoenyGive()
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 + 5
09                    wait(0.1)
10print("Money gave")
11else
12warn()
13                script:remove()
14            end
15        end
16    end
17end
18Humanoid.Died:connect(MoenyGive)

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I am not 100% but I believe "Leaderstats" should be with a lowercase, also its better if you use a higher case on connect, such as "Connecet"! I have also re-written your code and added a function to the :Connect.

This most likely won't work but give my attempt a shot.

01local Humanoid = script.Parent.Humanoid
02 
03Humanoid.Died:Connect(function(MoenyGive)
04 
05function MoenyGive()
06    local tag = Humanoid:findFirstChild("creator")
07    if tag ~= nil then
08        if tag.Value ~= nil then
09            local Leaderstats = tag.Value:findFirstChild("leaderstats")
10            if leaderstats ~= nil then
11                leaderstats.Coins.Value = leaderstats.Coins.Value + 5
12                    wait(0.1)
13print("Money gave")
14else
15warn()
View all 21 lines...

If this helps shoot me a reply.

0
@TgaTheGoldenArmour I got this output jmathewbat -13 — 4y
0
Workspace.Ice Zombie.Script:21: Expected 'end' (to close 'function' at line 3), got <eof>; did you forget to close 'then' at line 8 jmathewbat -13 — 4y
0
Add a bracket to the bottom end , e.g : end) TgaTheGoldenArmour 15 — 4y
0
i did and it showed up red jmathewbat -13 — 4y
View all comments (2 more)
0
Tomorow I will properly help you. TgaTheGoldenArmour 15 — 4y
0
ok jmathewbat -13 — 4y
Ad

Answer this question