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

Why doesn't my give cash script work once humanoid dies?

Asked by 5 years ago
Edited 5 years ago

So I have a script inside a model named "Brick" and the brick has a humanoid. Basically once you kill the brick, you will get points. However once I kill the brick, I'm not receiving any points. Any help?

local Humanoid = script.Parent.Humanoid
function Died()
    local p = Humanoid:findFirstChild("creator")
    if p ~= nil then
        if p.Value ~= nil then
            local Leaderstats = p.Value:findFirstChild("leaderstats")
            if Leaderstats ~= nil then
                Leaderstats.Points.Value = Leaderstats.Points.Value + 5

wait(0.1)

script:remove()

end

end

end

end

Humanoid.Died:connect(Died)
0
Please try actually indenting the code. Also, try to give your functions appropiate names, as when someone sees "YahYeet" They're not going to have a clue of what it's supposed to do. davidgingerich 603 — 5y
1
The script you did doesn't work because it is looking for the leaderstats inside of the thing you want to kill, instead, you should search for the leaderstats inside of the character that killed it. Hope this helps. AlanosoOficial 3 — 5y

Answer this question