Why does this animation budge the player?

I’m currently working for some attack animations for a project, but there is a bug where the animation snaps the player for a quick second.

Here is a gif of it happening: https://gyazo.com/d8eb6651038c220d8f659846c4cd9053

If you can’t watch it, whenever performing the attack, the player will sometimes snap and look at a different position for a second, but sometimes is fine.

I believe its something to do with the script, as the animation itself works fine in the animation editor and with the player. Here is the script, its very basic. There are no other custom animations playing, so it must be with this instance. The script is also a local script.

local UIS = game:GetService("UserInputService")
local slash = game.ReplicatedStorage.Slash
local cooldown = slash.Cooldown
local deb = 1
local meleeat = game.ReplicatedStorage.Remotes.MeleeAttack

local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://4765458718"

local chance = 1

UIS.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 and deb == 1 then
		deb = 2
		if chance == 1 then
			Animation.AnimationId = "rbxassetid://4765458718"
			chance = 2
		elseif chance == 2 then
			Animation.AnimationId = "rbxassetid://4765471971"
			chance = 1
		end
		local track = player.Character.Humanoid:LoadAnimation(Animation)
		track:Play()
		meleeat:InvokeServer()
		wait(cooldown.Value)
		track:Stop()
		deb = 1
	end
end)

The function “meleeat” is simply what deals the damage and creates the slash effect, it has nothing to do with the animation.

Not the case. The only thing that moves in this animation is the right arm. https://gyazo.com/80d0c69d938e398a3fc5ccd3d4cf5eb2
(This is both animations, the swipe left and right)

Their priority is core, I will try changing them to action

No change to the twitch, must not be that.

Can you try testing without the character following the mouse?

That fixed it. https://gyazo.com/b9c1e444de6cbd9f325f321c9b1a5720

Now the only issue is why does the character following the mouse cause this.

I think, when you click the mouse from the left or right side the position of the mouse changes by very little which causes the rotation.

1 Like

I got it. I have a hitbox for the slash beam, that goes from the floor to high up. Whenever you click, it clones that slash, and the hitbox. The players mouse then focuses on the hitbox instead of the ground, and causes movement.

Is there a way to make the hitbox undetectable to the mouse, or am I boned?
(Hitbox is cancollide off, as well as the slash texture itself)