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

What is wrong with this script? The output says: "attempt to call a nil value". What does that mean?

Asked by 7 years ago
Edited 7 years ago

What is wrong with this script? It won't damage the NPC. The output says: "attempt to call a nil value". What does that mean? Thanks for reading!

local animation = Instance.new('Animation')
local animTrack
local debounce = false
local player = game.Players.LocalPlayer

function onEquip()
   script.Parent.Handle.UnsheathSound:Play()
end

function onActivate()
    if not debounce then
    debounce = true
    if player.Character:FindFirstChild('ForceField') then player.Character.ForceField:Destroy() end
    animation.AnimationId = "http://www.roblox.com/asset/?id=129967390"
    animTrack = player.Character.Humanoid:LoadAnimation(animation)
    animTrack:Play()
    script.Parent.Handle.SlashSound:Play()
    function onTouched(hit)
        if not debounce then
            debounce = true
            if hit.Parent.Name:sub(1,17) == "AFK Noob Lv 1 HP " then
                hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25
                if hit.Parent.Humanoid.Health == 0 then
                    player.leaderstats.EXP.Value = player.leaderstats.EXP.Value + 16
                end
                wait(0.5)
                debounce = false
            elseif hit.Parent.Name:sub(1,4) == "Noob" then
                hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25
                wait(0.5)
            debounce = false
        end
    end
end
    wait(0.5)
    animTrack:Stop()
    debounce = false
    end
end

function onUnequip()
    animTrack:Stop()
end

script.Parent.Equipped:connect(onEquip)
script.Parent.Unequipped:connect(onUnequip)
script.Parent.Activated:connect(onActivate)
script.Parent.Handle.Touched:connect(onTouched)
0
You are problably trying to call something that does not exist yet ZeonMaxwelll 75 — 7y
0
Which lines are causing errors? The output doesn't tell me :c GatitosMansion 187 — 7y
0
Post the exact output you got. GoldenPhysics 474 — 7y
0
I posted it: "attempt to call a nil value" GatitosMansion 187 — 7y

Answer this question