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

how do i make a skill but it give stats when kill npc?

Asked by
vhelypogi -19
4 years ago
Edited 4 years ago

my reward script:

local Humanoid = script.Parent.Humanoid
function PwntX_X() 
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.Money.Value = Leaderstats.Money.Value + 3
wait(0.1)
script:remove()
            end 
        end 
    end 
end 
Humanoid.Died:connect(PwntX_X) 

2 answers

Log in to vote
0
Answered by 4 years ago

The folder leaderstats shouldn't be located in the creator tag, It should be located in the Player

0
so you know how to fix it? :( sorry im new vhelypogi -19 — 4y
0
and do i need to do anything with skill script? vhelypogi -19 — 4y
Ad
Log in to vote
0
Answered by
vhelypogi -19
4 years ago

i tried to fix my skill script, but it not give stats

script.Parent.OnServerEvent:Connect(function(plr)
    local Slash = game.ReplicatedStorage.Slash:Clone()
    Slash.Parent = workspace
    Slash.CanCollide = false
    Slash.Anchored = false
    Slash.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5) * CFrame.fromEulerAnglesXYZ(1.8,0,0)
    Slash.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= plr.Name then
            local Ball = game.ReplicatedStorage.Slash:Clone()
            Ball.Parent = workspace
            Ball.CFrame = Slash.CFrame * CFrame.new(0,0,0) * CFrame.fromEulerAnglesXYZ(math.random(-110,110),math.random(-110,110),math.random(-110,110))
            Ball.CanCollide = false
            Ball.Anchored = true
            Slash:Destroy()
            local creator = Instance.new("ObjectValue")
            local Debris = game:GetService("Debris")
            creator.Name = "creator"
            creator.Value = script.Parent.Parent.Parent
            Debris:AddItem(creator, 2)
            creator.Parent = hit.Parent.Humanoid
            hit.Parent.Humanoid:TakeDamage(5)
            for i = 1,18 do
                wait(.05)
                Ball.Size = Ball.Size + Vector3.new(2,2,2)
                Ball.Transparency = Ball.Transparency + 0.05
            end 
            Ball:Destroy()  
        end
    end)
    local BV = Instance.new("BodyVelocity",Slash)
    BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
    BV.Velocity = plr.Character.HumanoidRootPart.CFrame.LookVector * 80
end)

Answer this question