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

Nil Value In My Tool Animation Script?

Asked by 6 years ago
Edited 6 years ago
local gun = script.Parent
local aim = gun.aiming --boolvalue to toggle on and off

gun.Equipped:Connect(function()
    function onKeyPress(inputObject, gameProcessedEvent)
        local aim = script.aim
        if inputObject.KeyCode == Enum.KeyCode.Q then
            aim.Value = not aim.Value
            if aim.Value == true then
            local toggle = script.Parent.Parent.Humanoid:LoadAnimation(script.Aim)
            toggle:Play()
        elseif aim.Value == false then
            local toggle = script.Parent.Parent.Humanoid:LoadAnimation(script.Aim)
            toggle:Stop()
            end
        end
    end
end)

game:GetService("UserInputService").InputBegan:connect(onKeyPress)

In my gun tool I have a script that if you press q it would play an animation. If you press q again the animation will stop. My error is "attempt to call a nil value."

0
What line creeperhunter76 554 — 6y
0
It doesn't say a line in the error InfernoExeuctioner 126 — 6y
0
Click the error in Output, it will send you to the source. User#18043 95 — 6y

Answer this question