Unable to cast value to std::string

I’m getting so frustrated by this, I can’t seem to figure out the problem

local Data = DataStore:GetAsync(Player.UserId)
if Data then
		local Decoded = HttpService:JSONDecode(Data)
		if Decoded then
			print('YES')
			for i,v in pairs(Decoded.Tools) do
				print('Decoded')
				print(v.Name)
			end
			print('IDK')
		end
	else
		local NewTable = {
			Tools = {
				}
		}
local DataToEncode = HttpService:JSONEncode(NewTable)
DataStore:SetAsync(Player.UserId,DataToEncode)

This should print out the tools name stored inside the table, Instead I get that error when I decode

Which error is the line on? Also, I don’t see the purpose of encoding your data with JSON.

2 Likes

I found the issue, I sent unencoded data.

1 Like