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

Whenever I kill this npc, it won't give me exp. I think something is wrong with my weapon?.

Asked by 3 years ago

So, I'm a pretty new scripter and im making a script where the player kills an npc, he or she gains Exp and that exp can used to lvl up and unlock new fighting styles which hit more and harder, I feel like the problem is my weapon because it is a combat weapon that has fighting moves and animations and all that a combat system has, how would I make this script work for the player so when they kill the npc, they gain Exp

local Humanoid = script.Parent.Humanoid

function Dead()
    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.Exp.Value = leaderstats.Exp.Value + 10
                wait(0.1)
                script:Remove()
            end
        end
    end
end
Humanoid.Died:Connect(Dead)

2 answers

Log in to vote
0
Answered by 3 years ago

On line 11, I don't think :Remove is a thing. Replace that with :Destroy()

0
Nope, that didn't help Itz_Visually 17 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Are you using a LocalScript or Server Script?

Answer this question