Humanoid's animation doesn't play

  1. What do you want to achieve? Keep it simple and clear!
    i want to achieve that on key press, player can kick doors
  2. What is the issue? Include screenshots / videos if possible!
    the animation just doesn’t play but it prints in the output like it did
    can’t really attach file since my wifi is very very slow right now
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i looked all over but nothing helped me
    also tried to just disable all other animations but it just errors that “Animate is not a valid member”(Animate because i wanted to disable the script which just resumes them) but in properties i can very clearly see that it’s there

animation priority: action
script located: starterGUI
not any group animation
Code:

local char
repeat
	wait()
	char = game.Players.LocalPlayer.Character
until char
local hum = char:FindFirstChildWhichIsA("Humanoid")
repeat
	wait()
	hum = char:FindFirstChildWhichIsA("Humanoid")
until hum
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(inp,ign)
	if inp.KeyCode == Enum.KeyCode[script.Parent.controls.kickdoor.Value] and not ign then
		local anim = Instance.new("Animation")
		anim.AnimationId = "rbxassetid://8766667358"
		print(anim,anim.AnimationId)
		local a = hum:LoadAnimation(anim)
		print(a)
		a:Play()
	end
end)

Roblox deprecated Humanoid:LoadAnimation

Humanoid.Animator:LoadAnimation still doesn’t work tho and i prefer using humanoid:LoadAnimation

local player = game.Players.LocalPlayer
local char = player.CharacterAdded:Wait()
local hum = char:FindFirstChildOfClass("Humanoid")
local uis = game:GetService("UserInputService")
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://8766667358"
local a = hum:LoadAnimation(anim)

uis.InputBegan:Connect(function(inp,ign)
   if inp.KeyCode == Enum.KeyCode[script.Parent.controls.kickdoor.Value] and not ign then
   	a:Play()
   end
end)

I noticed ur code has a lot of un-needed lines, so i removed them and cleaned it up a bit, maybe try the code that i’ve given you above

yeah i just realized that too
but i tried your script and it didn’t even print anything in the output even when i inserted print

That is because I removed all your print statements :]

but i applied them again and both the animation and the print functions didn’t work

Are you sure you are using a LocalScript and not a server script?

yes, i’m not even sure how it would work with server one

local player = game.Players.LocalPlayer
local char = player.CharacterAdded:Wait()
local hum = char:FindFirstChildOfClass("Humanoid")
local uis = game:GetService("UserInputService")
local anim = Instance.new("Animation", script)
anim.AnimationId = "rbxassetid://8766667358"
local a = hum:LoadAnimation(anim)

uis.InputBegan:Connect(function(inp,ign)
   if inp.KeyCode == Enum.KeyCode[script.Parent.controls.kickdoor.Value]  then
   	a:Play()
   end
end)

Try using this script, i removed the gameloaded check from the InputBegan function, and I also suggest that you change it from Enum.KeyCode[script.Parent.controls.kickdoor.Value] to Enum.KeyCode.K or whichever key you prefer

still did not work
your script just kind of stopped on CharacterAdded for some reason, i applied print to both before the CharacterAdded and after and it only printed before the loading so like the characterAdded event never fires or something, i don’t know
also i don’t think this has to do with script since when i try my script it prints everything but just plays no animation.

Then its your animation. Is the animation owned by you?

yes, it’s published by me
and im pretty sure it loaded because when i did print to see how many objects remaining are in ContentProvider and it printed 0 so its not the fault of my connection

oh wait my rig was r15 instead of r6

1 Like
local userInput = game:GetService("UserInputService")

local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://8766667358"
local track = humanoid:LoadAnimation(animation)

userInput.InputBegan:Connect(function(key, processed)
	if processed then
		return
	end
	
	if track.IsPlaying then
		return
	end
	
	if key.KeyCode == Enum.KeyCode.F then
		track:Play()
	end
end)

Test this with the “F” key.