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.