How to make a buffering system?

I have my own character replication system that I am making, but I am very new to this topic, how can I implement buffers in this? like an interpolation buffer or some other kind so that I can prevent it from glitching out if the player lags

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local REPLICATION_UPDATE_RATE = 1/30

local replicateCharacterRemoteEvent = ReplicatedStorage.Events.RemoteEvents.ReplicateCharacter

local localPlayer = Players.LocalPlayer
local humanoidRootPart

local replicationCFrames = {}

task.spawn(function()
    while task.wait(REPLICATION_UPDATE_RATE) do
        if humanoidRootPart then
            replicateCharacterRemoteEvent:FireServer(humanoidRootPart.Position, humanoidRootPart.orientation, humanoidRootPart.AssemblyLinearVelocity)
         end
     end
end)

localPlayer.CharacterAdded:Connect(function(character)
	if character:FindFirstChild("HumanoidRootPart") then
		print(humanoidRootPart)
        humanoidRootPart = character.HumanoidRootPart
        if humanoidRootPart.Anchored == true then
            humanoidRootPart.Anchored = false
        end
        humanoidRootPart:GetPropertyChangedSignal("Anchored"):Connect(function()
            if humanoidRootPart.Anchored == true then
                humanoidRootPart.Anchored = false
            end
        end)
    end
end)

replicateCharacterRemoteEvent.OnClientEvent:Connect(function(player, position, orientation, assemblyLinearVelocity)
    if player.Character then
		if player.Character:FindFirstChild("HumanoidRootPart") then
            local targetCFrame = CFrame.new(position + assemblyLinearVelocity * REPLICATION_UPDATE_RATE) * CFrame.Angles(math.rad(orientation.X), math.rad(orientation.Y), math.rad(orientation.Z))
			replicationCFrames[player] = targetCFrame
        end
    end
end)

RunService.PreRender:Connect(function()
	for _, player in Players:GetPlayers() do
		if not replicationCFrames[player] then
			continue
		end
		if player == localPlayer then
			continue
		end
		if not player.Character then
			continue
		end
		if not player.Character:FindFirstChild("HumanoidRootPart") then
			continue
		end
		local currentCFrame = player.Character.HumanoidRootPart.CFrame
		player.Character.HumanoidRootPart.CFrame = currentCFrame:Lerp(replicationCFrames[player], 0.5)
	end
end)