I am saving some data in a data store for my anti exploit system, but whenever I store some data under a certain key, when I get that data, it says that it is nil.
I have done tons of testing, with print and warn statements, trying different values and keys, but I still am getting nil
This is actually my second version of this code, and it is pretty complex (interacting with other scripts), as well as not being finished, so I am only including the relevant parts of it.
local DataStoreService = game:GetService("DataStoreService")
local hackerData = DataStoreService:GetDataStore("hackerData")
local function tableToString(table1) #all this does is convert the tables from looking like this: 'table:9&b569c840r' to this: 'Table: test1, test2, test3'
if type(table1) == "table" then
returnedData = "Table: " .. table1[1]
for count = 2, #table1 do
returnedData = returnedData .. ", " .. tostring(table1[count])
end
else
returnedData = table1
end
return(returnedData)
end
local function setData(key, data)
local setSuccess, errorMessage = pcall(function()
hackerData:SetAsync(key, data)
end)
if not setSuccess then
if errorMessage then
warn(errorMessage)
end
warn("Couldn't add '", tableToString(data), "' to 'hackerData' under the key: '", key, "'")
else
warn("Added: '", tableToString(data), "' to 'hackerData' under the key: '", key, "'")
end
end
local function getData(key)
local getSuccess, data = pcall(function()
hackerData:GetAsync(key)
end)
if getSuccess then
warn("Got '", tableToString(data), "' from 'hackerData' under the key: '", key, "'")
else
warn("Couldn't get data from 'hackerData' under the key: '", key, "'")
end
return data
end
setData("HackDates", {"TestDate1", "TestDate2"})
function check(player, tpPlaceID)
warn("Server received teleport event")
warn("")
ogHackDates = getData("HackDates")
print(ogHackDates)
end
teleportSendEvent.OnServerEvent:Connect(check)
Here is what the output says:
The stuff I colored over is output from other parts of my code that i did not include here
