so i have been making a modulescript allowing u to create a private server using reserveserver however i want to assign it to another code thats shorter i did that but it says attempt to index nil with “code” so how do i insert the values like this
local table = {
[“qwewqrq”] = “private server key”
}
etc
and here is the code
local module = {}
local TS = game:GetService("TeleportService")
local DTS = game:GetService("DataStoreService")
local CodesDatastore = DTS:GetDataStore("CodesDatastore")
local alphabet = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}
local codetable = CodesDatastore:GetAsync("Codes")
function module:CreatePrivateServer(placeid)
local id
local succes, err = pcall(function()
id = TS:ReserveServer(placeid or game.PlaceId)
end)
if succes then
local code = ''
for i = 5,1,-1 do
local letter = alphabet[math.random(1,#alphabet)]
code = code..letter
end
codetable[code] = tostring(id)
local codeid = codetable[code]
print(codetable)
CodesDatastore:SetAsync("Codes",codetable)
else
print(err)
end
end
function module:GetCodes()
return codetable
end
return module