Moving & Replacing Positions on a Table

Hello!

Couldn’t find any forums explaining exactly what I am looking for. I’m looking to store values in a table, but once the Index exceeds 10 it starts replacing if that makes sense?

Eg; 10 values are stored, I now want to move all values up one number, delete number ten, and store my new value as [1].

Ill share my current code for the tables and server side script.

local StorageTable = {
	["Transmissions"] = {
		[1] = {["Callsign"] = "", ["Message"] = "", ["IsPanic"] = false},
		[2] = {["Callsign"] = "", ["Message"] = "", ["IsPanic"] = false},
		[3] = {["Callsign"] = "", ["Message"] = "", ["IsPanic"] = false},
		[4] = {["Callsign"] = "", ["Message"] = "", ["IsPanic"] = false},
		[5] = {["Callsign"] = "", ["Message"] = "", ["IsPanic"] = false},
		[6] = {["Callsign"] = "", ["Message"] = "", ["IsPanic"] = false},
		[7] = {["Callsign"] = "", ["Message"] = "", ["IsPanic"] = false},
		[8] = {["Callsign"] = "", ["Message"] = "", ["IsPanic"] = false},
		[9] = {["Callsign"] = "", ["Message"] = "", ["IsPanic"] = false},
		[10] = {["Callsign"] = "", ["Message"] = "", ["IsPanic"] = false},
	}
}

return StorageTable
local Storage = require(script.Parent.RadioStorage)

game.ReplicatedStorage.RadioEvents.sendChatter.OnServerEvent:Connect(function(recievedFrom : Player, callsign : string, message : string, shouldFilter : boolean)
	if not shouldFilter and recievedFrom.TeamColor then
		game.ReplicatedStorage.RadioEvents.sendChatter:FireAllClients(callsign, message, recievedFrom.TeamColor)
		
		> table.insert(Storage.Transmissions)
	end
end)
table.insert(StorageTable, 1,  {Callsign = " ", Message = " ", IsPanic = false })
while #StorageTable > 10 then
       table.remove(StorageTable, #StorageTable)
end
1 Like

Dont have the complete thing done yet, will let you know if it worked, thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.