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

How do i fix this error "Unable to cast value to Object" while loading an animation?

Asked by 4 years ago

So I have enounctered this error which says "Unable to cast value to objest" while loading an animation, and it doesn't say anything else, didn't find anything useful about this. And no i don't need debounce, and IsTyping, just need a fix for this, if possible.

Code:

wait(2) local Character = game.Players.PineRox.Character local UIS = game:GetService("UserInputService")

local Animation = Instance.new("Animation") Animation = 'rbxassetid://4682522673'

UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.F then local LoadAnimation = Character.Humanoid:LoadAnimation(Animation) LoadAnimation:Play() end end)

1 answer

Log in to vote
0
Answered by 4 years ago
wait(2)
 local Character = game.Players.PineRox.Character
 local UIS = game:GetService("UserInputService")

local Animation = Instance.new("Animation") 
Animation.AnimationId = 'rbxassetid://4682522673' --here's the error you need to put .AnimationId not the object animation

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.F then 
        local LoadAnimation = Character.Humanoid:LoadAnimation(Animation) 
        LoadAnimation:Play() 
    end 
end)
0
btw at line 1 you can change PineRox to LocalPlayer HappyTimIsHim 652 — 4y
Ad

Answer this question