Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

1 comment

0

Players.robot7866.PlayerScripts.LocalScript:13: attempt to index nil with 'Humanoid'

This discussion is preserved as it was. New answers, comments, and votes are closed.