Glitch with guns

Whenever the player is walking while shooting this is what happens:

robloxapp-20221221-2326511.wmv (1.4 MB)

	local function shoot()
		if Reloading then
			return
		end

		if Ammo.Value > 0 then
			local char = player.Character or player.CharacterAdded:Wait()
			local Shoot = char:WaitForChild("Humanoid"):LoadAnimation(Shoot)
			Ammo.Value -= 1

			local bulletDrop = Instance.new("Part")
			bulletDrop.Name = "bulletDrop"
			bulletDrop.BrickColor = BrickColor.new("Gold")
			bulletDrop.Size = Vector3.new(0.3, 0.1, 0.1)
			bulletDrop.CanCollide = false
			bulletDrop.Anchored = true
			bulletDrop.Parent = workspace

			bulletDrop.CFrame = Gun.Bullets.CFrame

			bulletDrop.Anchored = false

			game:GetService("Debris"):AddItem(bulletDrop, 1)

			Shoot:Play()

			if not newGun.Automatic then
				UseScope = false
				scope()
			end

			Gun:FindFirstChild("ShootParticle", true):Emit(1)

			Client_Server:FireServer("GunServer", newGun, mouse.Hit.p)

			local function returnRecoil(RAD, DontComplete)
				do
					local tween = TweenService:Create(
						camera,
						TweenInfo.new(0.05),
						{ CFrame = camera.CFrame * CFrame.Angles(math.rad(RAD), 0, 0) }
					)

					tween:Play()

					if DontComplete then
						tween.Completed:Wait()
					end
				end
			end

			--returnRecoil(10)
			-- task.wait(.05)
			-- returnRecoil(-10,true)
			--returnRecoil(5)

			if newGun.Automatic then
				camera.CFrame *= CFrame.Angles(math.rad(2.5), 0, 0)
			else
				camera.CFrame = camera.CFrame * CFrame.Angles(math.rad(10),0,0)

				task.wait(.05)

				TweenService:Create(
					camera,
					TweenInfo.new(.15),
					{CFrame = camera.CFrame * CFrame.Angles(math.rad(-10),0,0)}
				):Play()

				-- camera.CFrame *= CFrame.Angles(
				-- 	math.rad(camera.CFrame.X),
				-- 	math.rad(camera.CFrame.Y) + math.rad(10),
				-- 	math.rad(camera.CFrame.Z)
				-- )
				-- task.wait(1)
				-- camera.CFrame = CFrame.Angles(math.rad(camera.CFrame.X),math.rad(camera.CFrame.Y) - math.rad(10), math.rad(camera.CFrame.Z))
			end
		else
			UseScope = false
			scope()
			reload()
		end
	end

I think the main issue is around the recoil maybe?

“This happens” isn’t a good description. We don’t know exactly what you are referring to in the video.

When the player is moving while the gun is shooting the player’s arms just like go forwards and the camera is glitched behind

I’m guessing the camera.CFraming for the recoil is doing this. Because its not happening when I don’t use the camera.CFrame for my recoil. But then I need a recoil system so Idk what to do

Which way is your local Shoot = char:WaitForChild("Humanoid"):LoadAnimation(Shoot) animation playing? If your animation is reversed to the original animation it might be causing the gun to move forward instead of recoiling backward.

Also, you should load the Shoot Animation in the script before the if Ammo.Value > 0 line so it’s ready to be used. If you load it every time the ammo is greater than 0 you’ll get unneccessary lag.

1 Like

Are you animating the gun? (char 30)

Yes I am animating the guns I made an animation already