I found a bug in my fps system. How would I fix it?

I found a bug in my fps system where when the player dies, the camera and everything breaks. How would I fix it?

What its like normally:

What its like when you die:

The viewmodel breaks and its stuck where you last died.

Here is my script. Sorry its, not organised :pensive:

local player = game.Players.LocalPlayer


local camera = workspace.Camera

local run = game:GetService("RunService")

local arms = game.ReplicatedFirst.Arms:Clone()

local reloading = false
local inspecting = false

run.RenderStepped:Connect(function()
 
 arms:SetPrimaryPartCFrame(camera.CFrame * CFrame.new(0,0,0))
 
end)

local character = script.Parent 

local humanoid = character:WaitForChild("Humanoid")
local mouse = game.Players.LocalPlayer:GetMouse()
local sprinting = false

arms.Parent = camera

local animation = workspace.Animations.Animation0
local gunhumanoid = camera.Arms:WaitForChild('Humanoid')
local idle = gunhumanoid:LoadAnimation(animation)
idle:Play()
print("playing")

local walk = gunhumanoid:LoadAnimation(workspace.Animations.Animation1)
local click = gunhumanoid:LoadAnimation(workspace.Animations.Animation2)
local reload = gunhumanoid:LoadAnimation(workspace.Animations.Animation3)
local run = gunhumanoid:LoadAnimation(workspace.Animations.Animation4)
local Inspect = gunhumanoid:LoadAnimation(workspace.Animations.Animation5)
local run2 = gunhumanoid:LoadAnimation(workspace.Animations.Animation6)
local aim = gunhumanoid:LoadAnimation(workspace.Animations.Animation7)
local UserInputService = game:GetService("UserInputService")

local bullets = camera.Arms.Bullets.Value

local function onInputBegan(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.MouseButton1 and bullets > 0 then
		script.Parent.Humanoid.WalkSpeed = 0
		click:Play()
		bullets = bullets - 1	
		print(bullets)
		walk:Stop()
		run2:Stop()
		camera.Arms.M1911A1.ForBullet.Shoot:Play()
		game.ReplicatedStorage.RayCastEvent:FireServer(camera.Arms.M1911A1.ForBullet.Position, mouse.Hit.Position)
		camera.Arms.M1911A1.ForBullet.ParticleEmitter1.Enabled = true
		camera.Arms.M1911A1.ForBullet.ParticleEmitter2.Enabled = true
		camera.Arms.M1911A1.ForBullet.ParticleEmitter3.Enabled = true
		camera.Arms.M1911A1.ForBullet.PointLight.Enabled = true
		print("shot")
		wait(0.2)
		camera.Arms.M1911A1.ForBullet.ParticleEmitter1.Enabled = false
		camera.Arms.M1911A1.ForBullet.ParticleEmitter2.Enabled = false
		camera.Arms.M1911A1.ForBullet.ParticleEmitter3.Enabled = false
		camera.Arms.M1911A1.ForBullet.PointLight.Enabled = false
		script.Parent.Humanoid.WalkSpeed = 16
	end
end
UserInputService.InputBegan:Connect(onInputBegan)
local debounce1 = false
local cooldowntime1 = 4
local function onInputBegan(input, gameProcessed)
	--cooldown time
	if not debounce1 then

		if input.KeyCode == Enum.KeyCode.F and not debounce1 then
			Inspect:Play()
			walk:Stop()
			inspecting = true
			script.Parent.Humanoid.WalkSpeed = 0
			debounce1 = true
			print("reload")
			wait(0.5)
			script.Parent.Humanoid.WalkSpeed = 16

			wait(cooldowntime1)
			inspecting = false
		
			debounce1 = false
		end
	end
end

UserInputService.InputBegan:Connect(onInputBegan)
local debounce = false
	local cooldowntime = 2
local function onInputBegan(input, gameProcessed)
	 --cooldown time
	if not debounce then
		
	if input.KeyCode == Enum.KeyCode.R and not debounce and bullets < 7 then
			reload:Play()
			script.Parent.Humanoid.WalkSpeed = 0
			walk:Stop()
			run2:Stop()
			reloading = true
		debounce = true
			print("reload")
			wait(1)
			script.Parent.Humanoid.WalkSpeed = 16
		
			wait(cooldowntime)
			game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Visible = false
			bullets = 7
			print(bullets)
			reloading = false
		debounce = false
	end
end
end
UserInputService.InputBegan:Connect(onInputBegan)

script.Parent.Humanoid.Running:Connect(function(speed)
	if speed > 0 and reloading == false and inspecting == false and sprinting == false then
		run:Play()
	else
		run:Stop()
	end
end)

script.Parent.Humanoid.Running:Connect(function(speed)
	if speed > 0 and reloading == false and inspecting == false and sprinting == true then
		run2:Play()
		script.Parent.Humanoid.WalkSpeed = 20
	else
		run2:Stop()
		script.Parent.Humanoid.WalkSpeed =16
	end
end)

		UserInputService.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		sprinting = true
		
			end
		end)


		UserInputService.InputEnded:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		sprinting = false
			
			end
		end)

--local function onInputBegan(input, gameProcessed)
	--if input.UserInputType == Enum.UserInputType.MouseButton2 then
		--print("The right mouse button has been pressed!")
		--aim:Play()
	--end
--end

--UserInputService.InputBegan:Connect(onInputBegan)
while wait(1) do
	if bullets <= 0 then
			game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Visible = true
end

end



Help would be greatly appreciated!

Maybe when the character died, Delete the arms model using Humanoid.Died

That actually worked, thank you for your help!

Welp. Maybe simple solutions can do the job done.