I am trying to load an animation, and store it in a variable. I have looked at the roblox api, and based on what I see on that webpage, my code should work. My code is here:
game.ReplicatedStorage.RemoteEvents2.Spells.ignis.OnServerEvent:Connect(function(player) local loadedAnimation = player.Character.Humanoid:LoadAnimation(game.ReplicatedStorage.MelAnim.INC.AnimationId) loadedAnimation:Play() print("PLAYING") end)
As you can see, this should work (the directories are correct, but you will just have to take my word for that).
If there is something that I am missing, I would appreciate being told so. Otherwise, I am out of luck.
Happy scripting, and all help is welcomed.
Edit: Does the same thing if I combine the two lines:
game.ReplicatedStorage.RemoteEvents2.Spells.ignis.OnServerEvent:Connect(function(player) player.Character.Humanoid:LoadAnimation(game.ReplicatedStorage.MelAnim.INC.AnimationId):Play() print("PLAYING") end)
When you load an animation, you cannot use the ID. You need to use the animation object, basically ID is nearly pointless for playing sadly.
e.g:
game.ReplicatedStorage.RemoteEvents2.Spells.ignis.OnServerEvent:Connect(function(player) local anim = player.Character.Humanoid:LoadAnimation(game.ReplicatedStorage.MelAnim.INC) player.Character.Humanoid:LoadAnimation(game.ReplicatedStorage.MelAnim.INC):Play() print("PLAYING") end)
pls do stuff if it helped idk what that stuff is
And to answer your actual question, you cannot cast the Play() function to something that doesn't support it, such as an animationID as opposed to an animation object.