How would I make this script replicate the viewmodel animations on someones character?

I have currently made a quite nice fps system with a viewmodel but I need the animations to be replicated for the character too.

For some reason the characters gun only sticks in front of them and don’t animate but the viewmodel animations work perfectly fine.

I have tried looking over youtube tutorials and developer hub but nothing is working!

server script that adds gun to player like it would to a viewmodel

game.Players.PlayerAdded:Connect(function(plr)
	
	local set = game.ReplicatedStorage.Stuff.Gun:Clone()
	
	plr.CharacterAdded:Connect(function(char)
		
		local gunAttach = Instance.new("Motor6D",char.HumanoidRootPart)
		gunAttach.Part0 = char.HumanoidRootPart
		gunAttach.Part1 = set.BodyAttach
		set.Parent = char
		
	end)
	
end)

character animation loader (only for holding rn)

local plr = game.Players.LocalPlayer
local ams = game.ReplicatedStorage.Stuff:WaitForChild("Animations")
local mse = plr:GetMouse()
local chr = plr.Character or plr.CharacterAdded:Wait()

local hum = chr:WaitForChild("Humanoid")

repeat
	wait()
until chr:FindFirstChild("Gun")

local hold = hum:LoadAnimation(ams:WaitForChild("GunHold"))
hold.Looped = true
hold:Play()

viewmodel animation loader

local run = game:GetService('RunService')
local cam = game.Workspace.CurrentCamera
local set = game.ReplicatedStorage:WaitForChild("Arms"):Clone()
local plr = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local ams = set:WaitForChild("Animations")
local mse = plr:GetMouse()
local amo = 10
local chr = plr.Character or plr.CharacterAdded:Wait()
local gui = plr.PlayerGui:WaitForChild("AmmoUI")


local fireDelay = .3
local firing = false

local reloadingDelay = 2.1
local reloading = false

local loaded = false

local hum = chr:WaitForChild("Humanoid")
local empty = hum:LoadAnimation(ams:WaitForChild("GunEmpty"))

repeat
	wait()
until plr:WaitForChild("PlayerGui").LoadingScreen.Frame.Visible == false

print("done loading")

set.Parent = cam
run.RenderStepped:Connect(function()
	
	set:SetPrimaryPartCFrame(cam.CFrame*CFrame.new(0,0,0))
	
end)

local humanoid = set:WaitForChild("Humanoid")
local hold = humanoid:LoadAnimation(ams:WaitForChild("GunHold"))
hold.Looped = true
hold:Play()

mse.Button1Down:Connect(function()
	
	if amo > 1 then

		if firing == false and reloading == false and loaded == true then

			local humanoid = set:WaitForChild("Humanoid")
			local fire = humanoid:LoadAnimation(ams:WaitForChild("GunFire"))
			fire:Play()

			firing = true
			set.Gun.Receiver.Fire:Play()
			amo -= 1
			gui.Frame.Frame.Current.Text = tonumber(gui.Frame.Frame.Current.Text) - 1
			wait(fireDelay)
			firing = false

		end
		
	elseif amo == 1 then
		
		if firing == false and reloading == false and loaded == true then
			
			local humanoid = set:WaitForChild("Humanoid")
			local fire = humanoid:LoadAnimation(ams:WaitForChild("GunLastBulletFire"))

			fire:Play()
		
			firing = true
			set.Gun.Receiver.Fire:Play()
			amo -= 1
			gui.Frame.Frame.Current.Text = tonumber(gui.Frame.Frame.Current.Text) - 1
			hold.Looped = false
			empty.Looped = true
			empty:Play()
			wait(fireDelay)
			firing = false
			loaded = false
			
		end
		
	elseif amo == 0 then
		
		set.Gun.Receiver.Empty:Play()
		


		
		
		
		
	end


	
end)

local sliding = false

uis.InputBegan:Connect(function(input,gameProcessed)
	
	if gameProcessed then return end
	
	if input.KeyCode == Enum.KeyCode.F then
		
		if amo > 0 and reloading == false and firing == false and sliding == false then
			
			local humanoid = set:WaitForChild("Humanoid")
			local inspect = humanoid:LoadAnimation(ams:WaitForChild("GunThingy"))
			
			sliding = true
			
			inspect:Play()
			set.Gun.Slide.Back:Play()
			set.Gun.Slide.Back.Ended:Wait()
			set.Gun.Slide.Forward:Play()
			set.Gun.Slide.Forward.Ended:Wait()

			if loaded == false then
				loaded = true
			else
				amo -= 1
				gui.Frame.Frame.Current.Text = tonumber(gui.Frame.Frame.Current.Text) - 1

			end
			
			sliding = false
			
		end

	elseif input.KeyCode == Enum.KeyCode.R then
		
		local humanoid = set:WaitForChild("Humanoid")
		local reload = humanoid:LoadAnimation(ams:WaitForChild("GunReload"))
		
		if reloading == false and amo < 10 then
			
			empty.Looped = false
			set.Gun.Receiver.Reload:Play()
			reload:Play()
			reloading = true
			wait(reloadingDelay)
			reloading = false
			gui.Frame.Frame.Current.Text = 10
			amo = 10
			
		end
		
		
		
	end
	
end)