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)
COMMUNITY QUESTION
Whats the error with this kill npc money script? y output isnt help at all with this.
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
@TgaTheGoldenArmour I got this output
Workspace.Ice Zombie.Script:21: Expected 'end' (to close 'function' at line 3), got ; did you forget to close 'then' at line 8
Add a bracket to the bottom end , e.g : end)
i did and it showed up red
Tomorow I will properly help you.
ok