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

What is wrong with the 'Load Animation'?

Asked by 4 years ago
Edited by SerpentineKing 4 years ago
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'

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. AntiWorldliness 868 — 4y
0
Thx! EpicLLBro 11 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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)
Ad

Answer this question