Lag When NPC Unragdolls

So there is like an delay and doesnt play animations when the rake npc unragdolls like this
Also, this just happens playing the game normally, no in studio

But In studio works fine

This is my current script:

wait(0.25)

local replicated = game:GetService("ReplicatedStorage")
local storage = game:GetService("ServerStorage")
local rakedoll = storage:WaitForChild("RakeStunned")

local remote = replicated:WaitForChild("StunEvent")
local ragdolltime
local isragdolled = false

function ragdoll()
		if workspace:FindFirstChild("Rake") then
			print("Ragdolled Rake")
		local clone = rakedoll:Clone()
		clone.Parent = workspace
		ragdolltime = clone:WaitForChild("StunTime")
		wait()
		for i, v in pairs(clone:GetChildren()) do
			if v:IsA("BasePart") then
				v.CFrame = workspace.Rake.HumanoidRootPart.CFrame
			end
		end
	       wait(.1)
           workspace.Rake.Parent = storage
			
	    
    end
end


function unragdoll()
	if not workspace:FindFirstChild("Rake") then
			print("Unragdolled Rake")
			if storage:FindFirstChild("Rake") and workspace:FindFirstChild("RakeStunned") then
			workspace.RakeStunned:Destroy()
			wait(.1)
			storage.Rake.Parent = workspace

			end
		end
	end

remote.Event:Connect(function(player)--, dmg, ragdolltime)
	ragdoll()
	wait(.1)
	ragdolltime.Value = math.random(6,7)
	wait()
	repeat wait(1) ragdolltime.Value -= 1 until ragdolltime.Value <= 0
	  unragdoll()
end)