-
What do you want to achieve?
I want to decode a raw string from a datastore -
What is the issue?
An error (Argument 1 is missing or nil) is being thrown when passing in 1 argument (the string) so I’m guessing it’s the fact that it has no value…I’ve tried to fix it but I have no clue how to (I’m fairly new to JSON in Roblox) -
What solutions have you tried so far?
I’ve tried to handle it using an if-statement checking if it’s just an empty string or nil. I used print() to print out the value of it, but it came out ‘nil’ while I have it checking for nil?
Players.PlayerAdded:Connect(function(Player)
local function HandleNone()
print("NO CHARACTERS FOUND")
return
end
local CharacterValuesRawData = ""
local CharacterValues = {}
local Character1Values = {}
local Character2Values = {}
local Character3Values = {}
local Success, ErrorMessage = pcall(function()
CharacterValuesRawData = CharacterValuesDataStore:GetAsync(tostring(Player.UserId).."-CharacterValues")
end)
if not Success then
warn(ErrorMessage)
return
end
if CharacterValuesRawData == "" or nil then
HandleNone()
end
print(CharacterValuesRawData)
CharacterValues = HttpService:JSONDecode(CharacterValuesRawData)