Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Problem With Storing a Table With DataStore(?)

Asked by
lukeb50 631 Moderation Voter
8 years ago

im trying to make a script that gets a table from a datastore,picks a value at random, and returns it. here is the script so far:

script.Parent.RequestAdToShow.OnServerInvoke = function()
ds=game:GetService("DataStoreService"):GetDataStore("Impressions","TestService")
TestTabledtable=ds:GetAsync("Ads")
numb=#TestTable
id=math.random(1,numb)
line=adtable[id]
print(line)--should be the value
end

the table allready exists(tested with a plugin) and i get this error:

Workspace.AdService.ViewService:6: bad argument #2 to 'random' (interval is empty) 12:25:37.696 - Script 'Workspace.Part.SurfaceGui.Script', Line 6 12:25:37.698 - Stack End

the length of the table is reported by a print to be 0, but i tested it with a plugin and its at least 6 long i have tried everything i can think of, any ideas?

0
Your error is because the #TestTable is empty, meaning you have 0 or nil test tables. laughablehaha 494 — 8y

Answer this question