of     1   

electricfirestorm
#215493207Friday, April 28, 2017 6:28 PM GMT

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.
ExtremeBuilder15
#215493536Friday, April 28, 2017 6:37 PM GMT

local id = nil function updateBoard() id = v.Value end Just know that you can only have one id at a time
electricfirestorm
#215493754Friday, April 28, 2017 6:42 PM GMT

local ods = game:GetService("DataStoreService"):GetOrderedDataStore("UCRTime9") local id = nil function updateBoard(board, data) for k,v in pairs(data) do local pos = k 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 Changed to this - problem is it returns attempt to concatenate upvalue 'id' (a nil value)
ExtremeBuilder15
#215493784Friday, April 28, 2017 6:43 PM GMT

you have to capitalize the v in v.Value
electricfirestorm
#215493947Friday, April 28, 2017 6:47 PM GMT

Ok, Just done that but its still returning nil value, does not return this value when variable called within function.
ExtremeBuilder15
#215494027Friday, April 28, 2017 6:49 PM GMT

Actually, I'm not sure what you're iterating through, is this a free model?
electricfirestorm
#215494215Friday, April 28, 2017 6:53 PM GMT

Place here: https://www.roblox.com/games/752416863/UCR-Time-Capsule (I've uncopylocked it) Not a free model but based off Roblox Ordered Datastore Example online
MightyDantheman
#215494296Friday, April 28, 2017 6:55 PM GMT

local x = nil function y x = "z" end y() print(x) --Prints "z" ~MightyDantheman~
electricfirestorm
#215496515Friday, April 28, 2017 7:39 PM GMT

Still no further foward - that doesn't appear to be working.
MightyDantheman
#215506896Friday, April 28, 2017 10:31 PM GMT

Whoops, I meant this: local x = nil function y() x = "z" end y() print(x) --Prints "z" --// ~MightyDantheman~
Wunder_Wulfe
#215507189Friday, April 28, 2017 10:36 PM GMT

u can just put local vara, varb, varc... the = nil is already interpreted

    of     1