Why isn't my script loading the animation?

I am making a player controlled SCP 096 and he has a rage ability. Whenever they press E, it will load and play a charging animation. After 30 seconds, a rage animation will play. However, the script ends at this line here.
image

Why is it doing this?

local UIS = game:GetService("UserInputService")
local char = script.Parent

local head = script.Parent.Head
local hum = script.Parent.Humanoid

local keybind = Enum.KeyCode.E -- between the key for ability
local rage = true

local cooldown = 30

UIS.InputBegan:Connect(function(input,gameprocessed)
	if gameprocessed then return end
	if not rage then return end
	
	if input.KeyCode == keybind then
		rage = false
		
		local Charge = Instance.new('Animation')
		Charge.AnimationId = 'rbxassetid://14288885367'
		local PlayCharge = char.Humanoid:LoadAnimation(char)
		PlayCharge:Play()
		
		
		hum.WalkSpeed = 0
		head.Triggered:Play()
		wait(3.5)
		head.Charge:Play()
		wait(30.5)
		head.Charge:Stop()
		PlayCharge:Stop()
		head.Rage:Play()
		hum.WalkSpeed = 35
		
		local Rage = Instance.new('Animation')
		Rage.AnimationId = 'rbxassetid://14288872282'
		local PlayAnim = char.Humanoid:LoadAnimation(Rage)
		PlayAnim:Play()
		
		head.Ambience:Play()
		wait(25)
		head.Ambience:Stop()
		head.Rage:Stop()	
		hum.WalkSpeed = 8
		PlayAnim:Stop()
		
		wait(cooldown)
		rage = true
	end
end)

2 Likes

Char is not a animation instance, You should load the animation called “Charge”. I also recommend playing the animation on the Humanoid animator and not the humanoid.

3 Likes

Something like this should work,

local UIS = game:GetService("UserInputService")

local Char = script.Parent
local Head = Char:WaitForChild("Head")
local Humanoid = Char:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")

local keybind = Enum.KeyCode.E -- between the key for ability
local rage = true

local cooldown = 30

local RageAnim = script.Animation

UIS.InputBegan:Connect(function(input,Gp)
	if not Gp and input.KeyCode == keybind then
		if rage == true then	
			rage = false

			local Anim = Animator:LoadAnimation(RageAnim)
			Anim:Play()

			wait(cooldown)
			rage = true
		end
	end
end)
2 Likes


I keep getting this error ending the script.
image

2 Likes

You named the Variable wrong, it should be

local RageAnim = script.RageAnim

Make sure you have the right naming in the script

3 Likes


Still got this error, regardless how I named it.
image
Just so you know, you get the script via a morph.
image
image

2 Likes

Are you sure this is the right script you are sending me a view of in the error it says the script is located in an instance called “Nexxxussss”. However, The one you’re sending me a pic of is called 096.

3 Likes

you never set where you wanted your anims to be spotted
you should set the parent like so

local Charge = Instance.new('Animation')
Charge.AnimationId = 'rbxassetid://14288885367'
Charge.Parent = char
local PlayCharge = char.Humanoid:LoadAnimation(Charge)
3 Likes

I am very sure.


The script is pasted onto the player’s character.

2 Likes

Either do what Ayoub said or just do this local RageAnim = script:WaitForChild("RageAnim")

It is not a problem if the animation is not viewable inside of the explorer, because using that way of getting an animation makes it so that the animation instance doesn’t need a parent to still be usable inside a local script.

yeah but its still better to make things organized

he made a mistake in here by assigning the :LoadAnimation to the character itself while it should be the animation.

Yes, I saw that mistake, I pointed it out on the first post although I assume the script can’t find the child called RageAnim because the script loads before the RageAnim.

I just have one more question. And while the script does work now in playing the animations, it seems that the idle animation/walking animation still affect in how the charge/rage animation plays. The charge is set to Action3, while Rage is Action4. Walking is movement and idle is idle. Why does it still affect the way it looks?

are they the default roblox idle/walking animations?

no, they are custom made ones i made in moon animator. and they are located in an animate script.
image

are you sure that the priority of these animations are set to idle/movement?

I am sure. Whenever the charging animation plays, it does play, however, it still seems like the idle animation is effecting the way it is. For example, during the idle animation the humanoid is slouched down. But in the charging animation the arms just go up, thats it. But the humanoid is still slouched.

If the custom animation you made doesn’t move the torso at all then it won’t effect how the torso moves, try changing the rotation of the torso a bit. If that doesn’t work you can always just set the animation priority to action.

1 Like

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