Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

6 comments

0

@TgaTheGoldenArmour I got this output

0

Workspace.Ice Zombie.Script:21: Expected 'end' (to close 'function' at line 3), got ; did you forget to close 'then' at line 8

0

Add a bracket to the bottom end , e.g : end)

0

i did and it showed up red

0

Tomorow I will properly help you.

0

ok

This discussion is preserved as it was. New answers, comments, and votes are closed.