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 3 years ago
local Humanoid = script.Parent.Humanoid 
function MoenyGive() 
    local tag = Humanoid:findFirstChild("creator") 
    if tag ~= nil then 
        if tag.Value ~= nil then 
            local Leaderstats = tag.Value:findFirstChild("leaderstats") 
            if Leaderstats ~= nil then 
                Leaderstats.Coins.Value = Leaderstats.Coins.Value + 5
                    wait(0.1)
print("Money gave")
else
warn()
                script:remove()
            end 
        end 
    end 
end 
Humanoid.Died:connect(MoenyGive)

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 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.

local Humanoid = script.Parent.Humanoid 

Humanoid.Died:Connect(function(MoenyGive)

function MoenyGive() 
    local tag = Humanoid:findFirstChild("creator") 
    if tag ~= nil then 
        if tag.Value ~= nil then 
            local Leaderstats = tag.Value:findFirstChild("leaderstats") 
            if leaderstats ~= nil then 
                leaderstats.Coins.Value = leaderstats.Coins.Value + 5
                    wait(0.1)
print("Money gave")
else
warn()

                script:remove()
            end 
        end 
    end 
end 

If this helps shoot me a reply.

0
@TgaTheGoldenArmour I got this output jmathewbat -13 — 3y
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 — 3y
0
Add a bracket to the bottom end , e.g : end) TgaTheGoldenArmour 15 — 3y
0
i did and it showed up red jmathewbat -13 — 3y
View all comments (2 more)
0
Tomorow I will properly help you. TgaTheGoldenArmour 15 — 3y
0
ok jmathewbat -13 — 3y
Ad

Answer this question