I’m trying to create a code system for my game with a pastebin. Doing so, I can easily add codes without having to open studio and shut down the game every time I add or remove a code.
Pretty much how this works is that players enter a code, the script then grabs the code title, code prize, and code value from Pastebin.
An example could be that you enter a specific code and then receives a speed boost for 30 seconds. The prize would be “Speed” and the value would be 30.
I’m not entirely sure how JSON works and I can’t figure out the reason to why my code can’t parse JSON.
Pastebin Link: https://pastebin.com/kDaQLjj8
Here is the function I use when a code is entered:
local function enterCode(Code)
local pastebinLink = HttpsService:GetAsync(CodeURL)
if HttpsService:JSONDecode(pastebinLink) then
local data = HttpsService:JSONDecode(pastebinLink) -- get's the data from one code. code name, code prize and code value
if data[Code] then-- code is the actual code name, it finds it in the table
print("Code successful")
end
end
end
The line that doesn’t work is
if HttpsService:JSONDecode(pastebinLink) then
Not entirely sure what’s causing this and I would really appreciate help from you!
Thanks a lot