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

How do I make a Animation Play in my script error: attempt to index nil with 'Humanoid' ?

Asked by 3 years ago
Edited 3 years ago

Thanks for reading Please help me fix it the animation part is falling

local debounce = false
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local torso = workspace:FindFirstChild(player.Name)
mouse.KeyDown:connect(function(key)
    if key == "q" then
        if not debounce then
            debounce = true
            local part = game.ReplicatedStorage.Part:Clone()
            local part2 = game.ReplicatedStorage.Part:Clone()
            local part3 = game.ReplicatedStorage.Part:Clone()
            local Icep = game.ReplicatedStorage.Icep:Clone()
            local anim = torso.Humanoid:LoadAnimation(game.Workspace.Anim)
            wait(1)
            Icep.Parent = game.Workspace
            anim:Play()
            Icep.Position = torso.LeftHand
            part.Parent = game.Workspace
            part.Position = torso.UpperTorso.Positiona
            wait(3)
            part2.Position = torso.UpperTorso.Position + Vector3.new(0,6,0)
            part2.Parent = game.Workspace
            wait(2)
            part3.Position = torso.UpperTorso.Position + Vector3.new(0,7.5,0)
            part3.Parent = game.Workspace
            wait(8)
            debounce = false
            end
    end
    end)

1 answer

Log in to vote
0
Answered by 3 years ago
local debounce = false
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
repeat wait() until player.Character
local torso = player.Character
mouse.KeyDown:connect(function(key)
    if key == "q" then
        if not debounce then
            debounce = true
            local part = game.ReplicatedStorage.Part:Clone()
            local part2 = game.ReplicatedStorage.Part:Clone()
            local part3 = game.ReplicatedStorage.Part:Clone()
            local Icep = game.ReplicatedStorage.Icep:Clone()
            local anim = torso.Humanoid:LoadAnimation(game.Workspace.Anim)
            wait(1)
            Icep.Parent = game.Workspace
            anim:Play()
            Icep.Position = torso.LeftHand
            part.Parent = game.Workspace
            part.Position = torso.UpperTorso.Position
            wait(3)
            part2.Position = torso.UpperTorso.Position + Vector3.new(0,6,0)
            part2.Parent = game.Workspace
            wait(2)
            part3.Position = torso.UpperTorso.Position + Vector3.new(0,7.5,0)
            part3.Parent = game.Workspace
            wait(8)
            debounce = false
            end
    end
    end)

you had some spelling problems for example you typed Positiona instead of Position. Try this and if it gives error, tell me it

0
Players.robot7866.PlayerScripts.LocalScript:13: attempt to index nil with 'Humanoid' robot7866 36 — 3y
Ad

Answer this question