Any clue how to make this not error?

local rs = game:GetService("ReplicatedStorage")

local dummy = workspace.Dummy
local humanoid = dummy.Humanoid

local function respawn()
	dummy:Destroy()

	local dummy = game.ReplicatedStorage.Dummy
	local cd = dummy:Clone()

	cd.HumanoidRootPart.CFrame = dummy.HumanoidRootPart.CFrame
	cd.Parent = game.Workspace
end

humanoid.Died:Connect(respawn)

This works perfectly fine

No longer lags out the game but still only respawns once

Remove the dummy from ReplicatedStorage and test this inside the original dummy, also remove the script from serverscriptservice.

For some reason if you do not set a cooldown of at least 5 secs the script will return a nil value.

--variables
name="Humanoid"
dummy=script.Parent:clone()

while true do
	wait(5)
	
	--respawn
	if script.Parent.Humanoid.Health<1 then
		newdummy=dummy:clone()
		newdummy.Parent=script.Parent.Parent
		newdummy:makeJoints()
		script.Parent:remove()
	end
	--
	
end
		

It will probably still return a nil value but it will work.