Server Script optimization

local lastTime = getTime()
RunService.Heartbeat:Connect(function()
    local currentTime = tick()
    local deltaTime = currentTime - lastTime
    lastTime = currentTime

    for index, newEntity in ipairs(Entities) do
        local entityId = tonumber(newEntity.EntityId)
        local speed = newEntity.Speed
        local distanceTraveled = speed * deltaTime

        -- Update distance traveled for the entity
        newEntity.DistanceTravelled = (newEntity.DistanceTravelled or 0) + distanceTraveled

        -- Calculate progress for the entity
        local progress = newEntity.DistanceTravelled / totalDistance

        -- Update entity's progress
        newEntity.Progress = progress

        if progress >= 1 then
            ClientReplicator:FireAllClients("Destroy", tostring(entityId))
            table.remove(Entities, index)  -- Remove the entity from the table
        else
            serverPart.CFrame = newPath:CalculateUniformCFrame(progress)
            ClientReplicator:FireAllClients("UpdateProgress", tostring(entityId), progress)
        end
    end
end)

(This is server side script)
Can someone tell me how can I optimize that? I need to update the position of entities on client, position is calculated based on the progress which is saved in server side table, and also client side table. On client I’m updating the positions also every heartbeat. The progress is calculated based on total distance and distance that entity pass. I need as much as fast I can to update this information… My entity distance is added byy speed * deltaTime.

In case someone ask for client script:

Here’s how I update the position of entities on client

game:GetService("RunService").Heartbeat:Connect(function()

	for id, entitySaved in pairs(SavedEntities) do
		local newCframe = newPath:CalculateUniformCFrame(entitySaved.Progress)
		entitySaved["Model"]:PivotTo(newCframe)
	end
	
end)

The result I want to obtain smooth and synchronized movement of entities.