Animation Doesn't Play When Key Is Clicked

Hello! I am Ruben and I need help with scripting.

Basically I made a script so when the player presses the “R” key on their keyboard an animation will play. I tried doing this with a random animation I found on toolbox (it was a climbing animation), it worked. Then I tried with my own animation, now it doesn’t work, everything is the same, just different animation id.

The script is a LocalScript placed in StarterPlayerScripts:

local userInputService = game:GetService("UserInputService")

-- Front Roll
userInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.R then
		local player = game.Players.LocalPlayer
		local character = player.Character
		local humanoid = character:WaitForChild("Humanoid")
		
		local animation = script.Front_Roll
		local track = humanoid:LoadAnimation(animation)
		track:Play()
	end
end)

This is the script. ^^

2 Likes

Maybie cause you need to publish the animation

2 Likes

Make sure the animation is published onto the roblox website, under the game creator’s name.
If you upload the animation and it’s your friend’s place, the animation won’t play in studio.
Also make sure you uploaded the right Animation and you set AnimationPriority accordingly.

1 Like

Thank you, I will try to do it.

1 Like