Issue with loop in JSON

I use this script to check if the player has favorited the game, however, nothing is happening. I tried printing the result, and this is what it came out:
image
Script:

function CheckIfPlayerFavoritedTheGame(plr)
	local UserId = plr.UserId
	local Name = plr.Name
	local RawResponse = HttpService:GetAsync(string.format("https://games.roproxy.com/v2/users/%s/favorite/games?sortOrder=Asc&limit=10", tostring(UserId)))
	local Response = HttpService:JSONDecode(RawResponse)
	for _, obj in pairs(Response.data) do
		print(obj)
		if obj.id == game.PlaceId then
			print(string.format("%s favorited the game! Yay!",Name))
		end
	end
end

What do I need to change?

You can’t do this and it’s actually against the rules.

xJvn5J2

That’s why there’s no official API for it. Instead you could make a group and give benefits to people who join that group.

4 Likes

You literally took the answer from that post, didn’t you? I am not offering any prizes, I am trying to test and see my Http scripting level.

Would you mind expanding the tables’ content?

Why are you doing this

You can use this

local RawResponse = HttpService:GetAsync("https://games.roproxy.com/v2/users/" .. UserId .. "/favorite/games")

There’s no need for string.format just concat it with the userid and it should return the expected result.

What are you talking about? Both solutions achieve the same result and there is virtually no performance difference. Using string.format might just look “cleaner” and is more convenient to him than to concatenate 3 strings together.

the thing i sent is working for me, and the string.format is just unnecessary and takes up more space (my opinion at least)

Put this in tostring(). Ex: tostring(obj.id)

The content is just the information available: id, name, description etc.

Why? Both are strings.

Put both of them on tostring() that seems to fix it for me

It’s because the place Id is a number and the obj Id is a string from a json object

game.PlaceId returns a number. The comparation is correct.

You know its not that hard to try it and then tell me

First of all I can’t access the code right now, and second of all:
It’s a string if it has “”, it’s a number if it doesn’t, and is clearly a number digit.

It’s not that hard to wait until you can either I tested it without the tostring it doesn’t print, with it it does print, I also inputed manually the game Id and didn’t use the place Id and that works too.

Tested, doesn’t seem to work for me.

Try putting the game is in a string and not using game.PlaceId, example if tostring(obj.id) == “placeId” then

Seems to be a weird approach, but I get the same result.

I edited it try the edited thing now

I tried that too,