Issue with loop in JSON

Strange, it works for me though

How does it work? Does it print %s favorited the game! Yay!?

I replaced that with print(“found”) since i dont like using string.format for me it makes the code look messy. But that should work.

What? Just replacing a print doesn’t affect anything.

This is the code im using that actually works

function CheckIfPlayerFavoritedTheGame(plr)
	local UserId = plr.UserId
	local Name = plr.Name
	local RawResponse = game.HttpService:GetAsync("https://games.roproxy.com/v2/users/".. plr.UserId .. "/favorite/games")
	local Response = game.HttpService:JSONDecode(RawResponse)
	for _, obj in pairs(Response.data) do
		if tostring(obj["id"]) == "1457590906" then -- replace this "1457590906" with your actual game id that you want to check in a string.
			print("found")
		end
	end
end

game.Players.PlayerAdded:Connect(function(plr)
	CheckIfPlayerFavoritedTheGame(plr)
end)

I dont like string.format as i said, its really unnecessary when you can just concat it right away.

Does it print “found” Are you sure? It doesn’t for me. I added a else check and it printed “not found”.

It does, did you replace the game id with your own game id of the game that you have favorited?

Yes, ofcourse I did. But what is wrong?

Can you give me the script you are using now?

function CheckIfPlayerFavoritedTheGame(plr)
	local UserId = plr.UserId
	local Name = plr.Name
	local RawResponse = game.HttpService:GetAsync("https://games.roproxy.com/v2/users/".. plr.UserId .. "/favorite/games")
	local Response = game.HttpService:JSONDecode(RawResponse)
	for _, obj in pairs(Response.data) do
		if tostring(obj["id"]) == "the correct ID" then
			print("found")
		else 
			print("not found")
		end
	end
end

not found prints 20 times.

Do you actually have the game favorited? And also check the ID again you might have copied the wrong one.

Yes I checked the ID and have the game favorited. It shows on the API page, though.
image

Okay, try printing all of the objects, and then checking to see if the game is even there.

It is there. Not sure why, but twice.

I edited something along with the script:
obj["id"] to obj.rootPlace.id and it seemed to work. Thanks!