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 4 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

01local Humanoid = script.Parent.Humanoid
02 
03function Dead()
04    local tag = Humanoid:FindFirstChild("creator")
05    if tag ~= nil then
06        if tag.Value ~= nil then
07            local leaderstats = tag.Value:FindFirstChild("leaderstats")
08            if leaderstats ~= nil then
09                leaderstats.Exp.Value = leaderstats.Exp.Value + 10
10                wait(0.1)
11                script:Remove()
12            end
13        end
14    end
15end
16Humanoid.Died:Connect(Dead)

2 answers

Log in to vote
0
Answered by 4 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 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Are you using a LocalScript or Server Script?

Answer this question