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

Giving XP on death? [SOLVED]

Asked by 8 years ago

So my local script in the starterGUI is not giving XP on death of their own character. So when a person kills them, they get rewarded the XP. There are no errors so im guessing there is a problem at the "WaitForChild". I also tried to retrieve a value for "Character ". it returned nil

isDead = false

x = game.Players.LocalPlayer
Character = x:WaitForChild("Character") -- Problem?
Humanoid = Character:FindFirstChild("Humanoid")

Humanoid.Died:connect(function(onDeath)
    if not isDead then
        isDead = true
        local tag = Humanoid:findFirstChild("creator") 
        if tag ~= nil then
                local Folder = tag.Value:FindFirstChild("Folder")
                if Folder then
                    Folder.CurrentXP.Value = Folder.CurrentXP.Value + 1
            end  
        end
    end
end)

~ Thx, Bubs

3
The problem is that Character is not a child of Player, it is a property, so: repeat wait() until p.Character Character = p.Character TheDeadlyPanther 2460 — 8y
0
Wow, Thanks So much dude :). 10/10 for support Bubbles5610 217 — 8y
0
np TheDeadlyPanther 2460 — 8y
0
Could, you put [SOLVED] in the name of it so we know it's been solved? BinaryResolved 215 — 8y

Answer this question