Dictionary table not storing entry?

Hello I was working on server sided hitboxes for my game, for this I decided to work and fix some of roblox’s netcode so I am working on server sided lag compensation for server sided hitboxes

For this I have to store every player’s position every heartbeat on the server, I do this on a table and I have a function which rewinds all players positions and hitboxes to the time it was asked to
For testing purposes im always rewinding every player’s position to see if it was recording all player’s positions, but it only seems to record one player’s position
image

This was confusing to me because I made the script loop through all players

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

local IsDebugModeOn = true

local RPFolder = workspace.RewoundPositions

local RecordedHB = {}

local LagCompensator = {}

function LagCompensator.StartRecording()
	RunService.Heartbeat:Connect(function(DeltaTime)
		local CurrentTime = tick()
		
		RecordedHB[CurrentTime] = {
			["Players"] = {}
		}
		
		for Index,Player in pairs(Players:GetPlayers()) do
			
			if Player.Character then
				print(Player)
				RecordedHB[CurrentTime]["Players"] = {}
				RecordedHB[CurrentTime]["Players"][Player.UserId] = {}
				
				print("User Recorded",Player.UserId, Player.Name, CurrentTime, RecordedHB[CurrentTime]["Players"][Player.UserId])
				
				for i,v in pairs(Player.Character:GetChildren()) do
					if v:IsA("BasePart") then
	
						RecordedHB[CurrentTime]["Players"][Player.UserId][v.Name] = {
							["Size"] = v.Size,
							["CFrame"] = v.CFrame,
						}
						
					end
				end
			end
		end
		
		for Index1, Value in pairs(RecordedHB[CurrentTime]["Players"]) do
			print("Record Check",Index1, CurrentTime)
		end
		
		LagCompensator.RewindPositions(CurrentTime)
		
	end)
end

I added a few print functions on the script to diagnose what the problem was and based on the prints heres what I found out


You can see here how it states how it recorded the user’s position then when i get to the part where i check this it shows how only 1 user was recorded??? this is confusing to me as far as I know im using dictionary tables correctly

Anyways if anyone can point out what the issue is It would be appreciated.

Have you tried putting it in a playeradded event?

it has no need for a player event, it already gets the players with the for loop, and I tested it out with the print statements, using a player addded event to log the players who have joined is no difference if I just see what players are in the game, I also check if they have a character to prevent the script from failing if a player is unloaded.

I read the documentation again and realised something slipped off

In this part of the script turns out I am also clearing the table every time by setting it to blank
image
thats probably why it wasnt working, upon deleting this line the code worked, sorry for wasting anyone’s time.