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

attemt to index nil with 'Length' error?

Asked by 2 years ago

I have a script for inspecting a gun and playing an animation. But I keep getting the error above.

if not Reloading and ActuallyEquipped and Enabled and not AimDown and not Inspecting and Module.InspectAnimationEnabled then
                Inspecting = true
                if InspectAnim then InspectAnim:Play(nil,nil,Module.InspectAnimationSpeed) end
                if VMInspectAnim then VMInspectAnim:Play(nil,nil,Module.VMInspectAnimationSpeed) end
                local StartTime = tick() repeat game:GetService("RunService").RenderStepped:Wait() if ActuallyEquipped == false or Reloading == true or Enabled == false or AimDown == true then break end until (tick()-StartTime) >= InspectAnim.Length / InspectAnim.Speed
                Inspecting = false

The script is supposed to play the animation whenever another action isnt being done. For example, if the player is reloading or aiming, they cannot play the animation until after the action is done. But for some reason InspectAnim.Length is indexing as nil and I dont really know why. The script is a local script.

Answer this question