local ods = game:GetService("DataStoreService"):GetOrderedDataStore("UCRTime9")
function updateBoard(board, data)
for k,v in pairs(data) do
local pos = k
local id = v.value
local placesid = v.key
local slot = game.Workspace['slot'..pos].SurfaceGui
slot.ImageTest.Image= "h##################################################################################.placesid
position = id
end
end
while true do
-- wrap logic in pcall in case datastore request fails
local success, message = pcall(function()
local pages = ods:GetSortedAsync(false, 18)
-- get data for first board
local data = pages:GetCurrentPage()
updateBoard(game.Workspace.slot[position].SurfaceGui, data)
print("datastore loaded")
-- check if another page of data exists
if not pages.IsFinished then
-- if so then get data for second board
pages:AdvanceToNextPageAsync()
data = pages:GetCurrentPage()
updateBoard(game.Workspace.slot2.SurfaceGui, data)
end
end)
if not success then
print(message)
end
wait(10)
end
I need to access id variable outside of the function updateBoard, how would I achieve this, I've tried allocation a variable to the local variable but when I reference this outside of the function it returns nil.
|