--Playing the revive animation locally works a lot better than playing it server side

function game.ReplicatedStorage.RemoteFunctions.ReviveAnimation.OnClientInvoke(bodyPartsLocationTable, lastBranch)
	local respawnPosition = player.Character.Torso.CFrame
	for i = 1, #bodyPartsLocationTable["Head"] do
		if lastBranch ~= nil then
			if player.Character.Torso.Position.Z > lastBranch then
				break
			end
		end
		game:GetService("RunService").RenderStepped:wait()
		for key, value in pairs(bodyPartsLocationTable) do
			if player.Character:FindFirstChild(key) then
				if value[i] then
					player.Character[key].CFrame = value[i]
				end
			end
		end
		respawnPosition = player.Character.Torso.CFrame
	end
	player.Character:Destroy()
	return respawnPosition
end
