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

What is wrong with the 'Load Animation'?

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Animate
local Humaniod = player.Character:FindFirstChild("Humaniod")

mouse.KeyDown:Connect(function(Key)
	if Key == "c" then
		local Animation = Instance.new("Animation",player.Character)
		Animation.AnimationId = "rbxassetid://4934205080"
		Animate = Humaniod:LoadAnimation(Animation)
		Animation:Play()
	end
end)

mouse.KeyUp:Connect(function(Key)
	if Key == "c" then
		Animate:Stop()
	end
end)

The output says: Workspace.EpicLLBro.LocalScript:10: attempt to index nil with 'LoadAnimation'

2 comments

0

You spelled Humanoid wrong on line 4. It should be "player.Character:FindFirstChild("Humanoid"). You can keep your variable name spelled wrong if you'd like.

0

Thx!

1 answer

✓ Accepted answer

Some typos, don't worry! Also the Animation:Play() should be Animate:Play()

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Animate
local Humanoid = player.Character:FindFirstChild("Humanoid")

mouse.KeyDown:Connect(function(Key)
    if Key == "c" then
        local Animation = Instance.new("Animation",player.Character)
        Animation.AnimationId = "rbxassetid://4934205080"
        Animate = Humanoid:LoadAnimation(Animation)
        Animate:Play()
    end
end)

mouse.KeyUp:Connect(function(Key)
    if Key == "c" then
        Animate:Stop()
    end
end)

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