Why is my animation not playing?

It’s my first time animating a player, and so I am not sure what is wrong here. I created the animation on an r15 dummy and set avatar game settings to r15.
Here is the script:

--variables and instances

local char = script.Parent

local human = char:WaitForChild("Humanoid")

local root = char:WaitForChild("HumanoidRootPart")

local Animation = (Instance.new("Animation",human))

local Animator = (human.Animator)

Animation.AnimationId = "rbxassetid://11495468435"

local run = human:LoadAnimation(Animation)

game.Workspace.AnimSaves1.Parent = human

local uis = game:GetService("UserInputService")

--functions

uis.InputBegan:Connect(function(input)

	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.W then
			run:Play()
		end
	end
end)

you forgot run:Play()???
All i want for christmas is the 30 words removal!

1 Like

Is the run:Play() not allowed to be in a function? I’m confused.

Change:

local char = script.Parent

To:

local Player = game.Players.LocalPlayer
local char = Player.Character

It doesn’t seem to change anything.

Change: (Instance.new("Animation",human)) to: (Instance.new("Animation",root)), maybe, that’ll fix this.

I think there may be a default head animation playing and it overwrites my animation? Idk.

I think you should do a Local of the AnimationId, because if it doesn’t do the AnimationId, this could be the problem.

--variables and instances

local Player = game.Players.LocalPlayer
local char = Player.Character
local human = char:WaitForChild("Humanoid")
local root = char:WaitForChild("HumanoidRootPart")
local Animation = (Instance.new("Animation",human))
local Animator = (human.Animator)
local AnimationId = "rbxassetid://11495468435"
local run = human:LoadAnimation(AnimationId)
game.Workspace.AnimSaves1.Parent = human
local uis = game:GetService("UserInputService")

--functions

uis.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.W then
			run:Play()
		end
	end
end)

If it doesn’t work, I have seriously no words.

Error: “unable to cast Value to Object”

Hmm, where is the line of the issue, now?

local run = human:LoadAnimation(AnimationId)

Should be done:

--variables and instances

local Player = game.Players.LocalPlayer
local char = Player.Character
local human = char:FindFirstChildOfClass("Humanoid")
local Animation = (Instance.new("Animation",human))
local Animator = human.Animator
Animation.AnimationId = "rbxassetid://11495468435"
local run = human:LoadAnimation(Animator and Animation)
game.Workspace.AnimSaves1.Parent = human
local uis = game:GetService("UserInputService")

--functions

uis.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.W then
			run:Play("rbxassetid://11495468435")
		end
	end
end)

Hmmm. Do you know if the FirstPersonLock property of cameraMode makes the camera follow your head? Because I cannot feel any difference when playing.

Hmm, the Animator is an error-type, so do this:

--variables and instances

local Player = game.Players.LocalPlayer
local char = Player.Character
local human = char:FindFirstChildOfClass("Humanoid")
local Animation = (Instance.new("Animation",human))
local Animator = human.Animator
Animation.AnimationId = "rbxassetid://11495468435"
local run = human:LoadAnimation(Animation)
game.Workspace.AnimSaves1.Parent = human
local uis = game:GetService("UserInputService")

--functions

uis.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.W then
			run:Play("rbxassetid://11495468435")
		end
	end
end)

None of the scripts really change anything. It’s just not loading.

It might have something to do with the ownership of the animation. If you published the animation under a group and the experience you’re working on is under your account (or vice versa), the animation won’t be able to load. Is the experience and animation published under the same owner?

Yes. It is mine. Although it is a test so the animation itself is just to test if the script works (which it doesn’t)

Anyways. I will try looking for help elsewhere.
If anyone has an idea to fix this, feel free to reply.

Could be because the AnimationPriority value is set too low. The default is “Core,” so try setting it to “Action.”
image

More info regarding AnimationPriority

1 Like

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