Alright, Im stumped. Making a table only allow 4 keys

Well im currently making my fretta gamemode. And I want the votemap at the end to only have 4 random maps.

This is the code thats used to retrieve the maps for the votemap.

[lua]for _, mapname in pairs( AllMaps ) do
for _, p in pairs( info.fretta_maps ) do
if ( string.find( mapname, p ) ) then
table.insert( g_PlayableGamemodes[ gm.Name ].maps, mapname )

Tried a few things that I could think of. Anybody got a suggestion?

for i = 1, 4 do
local randomMap = table.Random( tableformaps );

table.insert(g_PlayableGamemodes(gmod.GetGamemode().Name).maps, randomMap);


Probably do something like that.

That was my first though, But the other 2 for loops run though every map. So it ends up adding like 4 duplicate maps each time

Just have the table for the maps retrieve the list of maps from the maps folder and have the code run when the gamemode is initialized. If there are duplicates, just empty the table before you add anything.

Lol I tried that as well. For some reason fretta didnt like it. The table returned nil on the votemap. But I made a command to print the whole table and it wasnt nil. Before and after the votemap.

Im just gonna rewrite the votemap. I dont need the gamemode voting lol

Was it trying to call that table from client when the table was serverside? Is it networked?

Its sent by datastream, Appearently as they spawn. Its probably my mistake somewhere though

You’re sending from server to client? Use a usermessage then.

Its fretta bro, And its a whole table.