I need help with my animation script its a keybind one. When I press J the first time everything works but if I try again it says "LoadAnimation requires an Animation object", and it says the error is on line 15. Here is my script:
local UIS = game:GetService('UserInputService')
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local Key = 'J'
local Animation = Instance.new('Animation')
Animation.AnimationId = 'rbxassetid://4594975382'
UIS.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
local KeyPressed = Input.KeyCode
if KeyPressed == Enum.KeyCode[Key] then
print(plr.Name..' has pressed'..Key)
local Load Animation = Char.Humanoid:LoadAnimation(Animation)
Load = Animation:Play()
end
end)

1 comment
Thanks so much!