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

My NPC will not give any Gold, no errors in Output. It's ment to give gold which go to stats. Help?

Asked by 7 years ago
Edited 7 years ago
function Reward()
    Humanoid = script.Parent:FindFirstChild("Humanoid")
    if Humanoid ~= nil then
        Creator = Humanoid:FindFirstChild("creator")
        if Creator ~= nil then
            if Creator.Value ~= nil then
            local leaderstat = Creator.Value:FindFirstChild("leaderstat")
            if leaderstat ~= nil then
                if Creator.Value.Character ~= nil then
                    leaderstat.Jewel.Value = leaderstat.Jewel.Value + 100
                    end
                end
            end
        end
    end
end

script.Parent.Humanoid.Died:connect(Reward)

Location of what i'm trying to get too: game.Players.LocalPlayer.leaderstat.Jewel.Value

NOTE: No errors in output :/

0
Bump. EvolutionPower 0 — 7y
0
What is the 'Creator.Value'? Im_Kritz 334 — 7y

1 answer

Log in to vote
0
Answered by
Voltoxus 248 Moderation Voter
7 years ago
Edited 7 years ago

Your code is confusing please refine what you want to happen. I think this is what you want?

LOCAL SCRIPT

game.Players.LocalPlayer.Character.Humanoind.Died:connect(function()
    if game.Players.LocalPlayer:FindFirstChild("leaderstats") and game.Players.LocalPlayer:FindFirstChild("leaderstats"):FindFirstChild("Jewel") then
        game.Players.LocalPlayer.leaderstats.Jewel.Value = game.Players.LocalPlayer.leaderstats.Jewel.Value + 100
    end
end)

Ad

Answer this question