Animation not playing correctly

I have successfully scripted a “swing bat” animation, but it does not play fully. The ingame result is here:

And the actual Animation Editor result is here:

Additionally, is there any way to make the bat look more like a swing in actual baseball? An example is listed below.

Here is my code:

local plr = game:GetService("Players").LocalPlayer
local anims = {script.Parent.Hold, script.Parent.Swing}
local loadedAnims = {}
local tool = script.Parent
local animator
local debounce = true
local del = 2
tool.Equipped:Connect(function(mouse) --On tool equipped do:
	animator = plr.Character:WaitForChild("Humanoid"):WaitForChild("Animator") --Find the animator object
	if not loadedAnims[1] then --If the animation wasn't loaded before
		loadedAnims[1] = animator:LoadAnimation(anims[1]) --Load it
	end
	loadedAnims[1]:Play()	--Play it
	
end)

--Click animation:
tool.Activated:Connect(function()
	if(debounce) then --Setting up the debounce (cooldown)
		debounce = false
		animator = plr.Character:WaitForChild("Humanoid"):WaitForChild("Animator") --Find the animator object
		if(not loadedAnims[2]) then --If the animation didn't exist yet
			loadedAnims[2] = animator:LoadAnimation(anims[2]) --Load it
		end
		loadedAnims[2]:Play() --Play it
		
		wait(del) --Wait the cooldown
		debounce = true
	end
end)

tool.Unequipped:Connect(function()
	loadedAnims[1]:Stop() 
	if(loadedAnims[2]) then 
		loadedAnims[2]:Stop()
	end
end)

Thanks for any help!

1 Like

I’m a very VERY good animator, I suggest bending the legs, move the lowertorso down and bend the legs, also bend the arms instead of having the sticking out, also dont use the move tool on animations, only rotate. Also learn roblox’s rig anatomy better, your bending bones in ways the shouldnt be moving, i suggest turning on ik.

it played your animation fully, i think you meant the animation goes back to the idle pose? your animation ended so when that happens it puts you back to your roblox defualt idle pose.

3 Likes

I meant that the arms don’t extend all the way as shown in the example video.

1 Like

Have you set the AnimationPriority of the swing animation to Action (or maybe lower)? When multiple animations of the same priority plays, the character can get buggy playing the animations.

You should try rotating the torsos too, as the video shown.

1 Like

I fixed the animations for the body and turned on ik, but I would like to ask how to make the bat look like it is in the left hand instead of the right.

Edit: Also to make the bat follow the left hand so it goes up with the left hand.

This looks like an issue related due to WeightedAnimationBlendFix, However do not disable it as it will be forced on all games, instead go to the animator and change your animation priority to action or higher

When you have 2 animations with the same priority playing at the same time with weighed animation blend fix the latest played animation will not override the last one anymore.

3 Likes

That worked, thanks! Is there any way I can move the bat to the left hand and make it follow the left hand?

You mean animate the bat itself asides from the arms?

This solved my issue aswell thank you so much!

1 Like

Im glad 2 years later my crusty answer also helped someone else