Animation getting stuck

Hello! I am currently making a lightsaber for my game and am having a problem with an animation. Here is a video of the problem:

As you see, when I try to go from blocking back to idle, the animation gets stuck and my character is stuck in a permanent position.

Here is the code for blocking:

if inputState == Enum.UserInputState.Begin then
		local toolEquipped = character:FindFirstChildWhichIsA("Tool")
		if toolEquipped then
			if toolEquipped.Name == "Lightsaber" then
				if ignited then
					local hum = character:FindFirstChild("Humanoid")
					local blocking = script.Parent.Blocking.Value
					if blocking == false then
						print("blocking")
						if IdleAnim ~= nil then
							IdleAnim:Stop()
						end
						local BlockingAnim = hum:LoadAnimation(script.Parent.Animations.Blocking)
						BlockingAnim:Play()
						script.Parent.Remotes.Block:FireServer()
					end
				end
			end
		end
	elseif inputState == Enum.UserInputState.End then
		local toolEquipped = character:FindFirstChildWhichIsA("Tool")
		if toolEquipped then
			if toolEquipped.Name == "Lightsaber" then
				if ignited then
					local hum = character:FindFirstChild("Humanoid")
					local blocking = script.Parent.Blocking.Value
					if blocking == true then
						print("unblocking")
						if BlockingAnim ~= nil then
							BlockingAnim:Destroy()
						end
						if IdleAnim == nil then
							IdleAnim = hum:LoadAnimation(script.Parent.Animations.Idle)
						end
						IdleAnim:Play()
						script.Parent.Remotes.Unblock:FireServer()
					end
				end
			end
		end
	end

Any help is appreciated.

I think the issue is that you called :Destroy() forBlockingAnim instead of :Stop()

1 Like

I tried stop at first and the same thing happened.

I can test it with stop again though.

Yeah, the same thing happens when I use :Stop() instead of :Destroy()

I fixed the issue. The issue was instead of saying BlockingAnim = hum:LoadAnimation(script.Parent.Animations.Blocking) I said local BlockingAnim = hum:LoadAnimation(script.Parent.Animations.Blocking). This caused the animation to jam.

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