How would i make the hand move when it shoots gun

so basically i have a npc that points to the nearest player, and i don’t know how to make it appear to have recoil when it fires

like for the recoil i just want the hand to move up then down and back up

video of the npc pointing at player

and here’s a video of me trying to simulate what kinda want

Are you using while loop to check if any player is near the npc?

i mean its sorta like a while loop?

Then you would probably want to add A debounce checking if the npc has fired the gun then increasing it’s X axis to about 45 degrees, or something like that.

im not sure if i can increase the x axis, because depending on its position it might be different

and here’s my script btw

local Players = game:GetService("Players")

local run = game:GetService("RunService")

local guards = {}

local function findClosestPlayer(position)
	local closestPlayer
	local closeDistance = 25
	for _, player in pairs(Players:GetChildren()) do
		local distnace = player:DistanceFromCharacter(position)
		if distnace < closeDistance then
			closeDistance = distnace
			closestPlayer = player
		end
	end
	return closestPlayer
end

run.Heartbeat:Connect(function()
	for index, guard in ipairs(guards) do
		local player = findClosestPlayer(guards[index]["guard"].Position)
		if player then
			guards[index]["attach"].WorldCFrame = CFrame.lookAt(guards[index]["attach"].WorldPosition, player.Character.PrimaryPart.Position)
		else
			guards[index]["attach"].CFrame = guards[index]["resetCF"]
		end
	end
end)

module = function(index, guard)
	local amongus = guard.PrimaryPart
	guards[index] = {amongus}
	
	guards[index]["guard"] = amongus
	guards[index]["attach"] = amongus:FindFirstChild("attach")
	guards[index]["resetCF"] = guards[index]["attach"].CFrame

	--attach.WorldCFrame = CFrame.lookAt(attach.WorldPosition, Vector3.new(part.Position.X,part.Position.Y,part.Position.Z))
end

return module

You can still add it just create a debounce to stop the npc looking at the player.

yeah but how do i make it go up, im using attachments to control the hand
and im using aligned position and aligned orientation