Hold Gun animation clipping back?

So as seen in this video, my hold gun animation is stopping for like a split second then continue’s back again.

robloxapp-20200511-1406162_Trim.wmv (322.5 KB)

SCRIPT

local tool = script.Parent
local player = game:GetService(“Players”).LocalPlayer
local CanShoot = true
local CurrentAmmo = script.Parent:WaitForChild(“CurrentAmmo”)
local Clip = 7
local ShootSpeed = 0.75
local UIS = game:GetService(“UserInputService”)
local Reloading = false
GUI = script.Parent:WaitForChild(“PistolAmmoGui”)
local HoldAnimation = game.Players.LocalPlayer.Character:WaitForChild(“Humanoid”):LoadAnimation(script.Parent.Hold)
local ShootAnimaton = game.Players.LocalPlayer.Character:WaitForChild(“Humanoid”):LoadAnimation(script.Parent.Shoot)

function StopHolding()
HoldAnimation:Stop()
end
script.Parent.Unequipped:Connect(StopHolding)

function Reload(input, processed)
if input.KeyCode == Enum.KeyCode.R and Reloading == false and script.Parent.Stock.Value >0 and script.Parent.CurrentAmmo.Value ~= Clip then
CanShoot = false
Reloading = true
print(“Reloading”)
wait(3)
script.Parent.CurrentAmmo.Value = Clip
script.Parent.Stock.Value = script.Parent.Stock.Value - 1
GUI.TextLabel.Text = script.Parent.CurrentAmmo.Value … " / " … script.Parent.Stock.Value
CanShoot = true
Reloading = false

end
end
UIS.InputBegan:Connect(Reload)

tool.Equipped:Connect(function(mouse)

HoldAnimation:Play()

mouse.Button1Down:Connect(function()
	if CanShoot and CurrentAmmo.Value >= 1 and Reloading == false then

	CurrentAmmo.Value = CurrentAmmo.Value - 1
	print(CurrentAmmo.Value)
	ShootAnimaton:Play()
	script.Parent.Handle.Shoot:Play()
	local ray = Ray.new(script.Parent.BulletHole.CFrame.Position - Vector3.new(0,math.random(0,1),0), (mouse.Hit.p - tool.Handle.CFrame.p).unit * 300)
	local part, position = workspace:FindPartOnRay(ray, player.Character)
	local beam = Instance.new("Part", workspace)
	beam.BrickColor = BrickColor.new("New Yeller")
	beam.FormFactor = "Custom"
	beam.Material = "Neon"
	beam.Transparency = 0.25
	beam.Anchored = true
	beam.Locked = true
	beam.CanCollide = false
	local distance = (tool.Handle.CFrame.p - position).magnitude
	beam.Size = Vector3.new(0.1, 0.1, distance)
	beam.CFrame = CFrame.new(tool.BulletHole.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
	game:GetService("Debris"):AddItem(beam, 0.2)
	
	GUI.TextLabel.Text = script.Parent.CurrentAmmo.Value .. " / "  .. script.Parent.Stock.Value
	
 	if not part then
	CanShoot = false
	wait(ShootSpeed)
    CanShoot = true	
	else


		local humanoid = part.Parent:FindFirstChild("Humanoid")
		
		if not humanoid then
			CanShoot = false
			humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
			wait(ShootSpeed)
			CanShoot = true
			
		end

			if humanoid and part.Name == "Head" then
			print("HeadShot")
			CanShoot = false
			humanoid:TakeDamage(math.random(15,25))
			wait(ShootSpeed)
			CanShoot = true
			
	     	elseif humanoid then
			CanShoot = false
			humanoid:TakeDamage(math.random(7,15))
			wait(ShootSpeed)
			CanShoot = true
			
			
			
		end
		end
	end
	end)
end)

How do I like fix that? the animation priority is Action and it’s set on loop

1 Like

I’m confused can you pin point the problem?

1 Like

Watch the video, as you can see the animation is like clipping back to the normal tool hold as it finishes it’s part of the loop, how do I fix that?

Oh crap, I didn’t saw that there was a small empty space on my animation, I didn’t notice it because my screen resolution is small. Well thanks anyways :')

glad to hear the problem is solved :slight_smile:

1 Like