"LoadAnimation is not a valid member of Humanoid "Workspace.Username.Humanoid"

I still don’t understand how this even exist…

I’m working on some animation stuff for a game I’m working on and I’ve been having issues trying to load and play a simple animation I created. I cannot figure out how to fix this, as Roblox Studio throws this error (which is the title of this post) at me for when I use the item.

I’m losing my mind over it and I still l can’t seem to find any sort of post that solves this issue, so please if anyone knows how animations work in Roblox Studio, help!

For anyone wondering, I’ve tried swapping from a Script to a LocalScript, changed where some variables go, and I’ve checked the AnimationIds.

Here’s the script so anyone can help…

local Tool = script.Parent;
local enabled = true

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChildOfClass("Humanoid")

local DrinkCola = Instance.new("Animation")
DrinkCola.AnimationId = "rbxassetid://129257978377171"
local DeathAnim = Instance.new("Animation")
DeathAnim.AnimationId = "rbxassetid://108731674990495"

local function onActivated()
	local DrinkTrack = Humanoid:LoadAnimaton(DrinkCola)
	local DeathTrack = Humanoid:LoadAnimation(DeathAnim)
	
	DrinkTrack.Looped = false
	DeathTrack.Looped = false

	if not enabled then
		return
	end

	enabled = false
	Character:WaitForChild("HumanoidRootPart").Anchored = true
	DrinkTrack:Play()

	Tool.Handle.DrinkSound:Play()

	task.wait(6)

	Tool.Handle.Scream:Play()
	DeathTrack:Play()
	task.wait(0.5)
	Humanoid.Health = 0
	Tool.Handle.Scream:Stop()
	task.wait(0.03)
	Character:Destroy()

	-- Safe guard for when player's character doesn't load in after reset
	task.wait(3)
	Player:LoadCharacter()

	enabled = true

end

local function onEquipped()
	Tool.Handle.OpenSound:play()
end

script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)

Yes, some parts are from a Bloxy Cola script, but I’m improvising it a little bit.

you have a typo local DrinkTrack = Humanoid:LoadAnimaton(DrinkCola)

1 Like

I was losing my mind… over a typo? Gosh I have to be better at tracking how I type, but thank you for noticing that.

Instead of Humanoid:LoadAnimation(), you should ideally be using Humanoid.Animator:LoadAnimation(). Your solution is correct but that way of loading the animation is deprecated and Roblox encourages you to use the one I have provided.

3 Likes

Thanks for letting me know that, this would be useful in the future.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.