[SOLVED] StringValue is not reading the Gamepass ID

Hello, I am having an issue with a certain line in the script. I don’t know how to explain it well but my issue is at the 6th line: if g.Value == ID then

The goal that I am trying to achieve is that if the ID of the gamepass (purchasedPassID) matches the string value (“ID”) that is located inside the replicated storage then it would print: "This stringvalue matches with the gamepass: " … ID (The ID number of both purchasedPassID and the StringValue)

Here is the script:

Summary
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedPassID, purchaseSuccess)
	local ID = purchasedPassID
	if purchaseSuccess ==  true and purchasedPassID == ID then
		for _, g in pairs(Things:GetDescendants()) do
			if g:IsA("StringValue") and g.Name == "ID" then
				if g.Value == ID then -- **This is the part that is not working. THE CURRENT ISSUE THAT I AM HAVING TROUBLE WITH**
					print("This stringvalue matches with the gamepass: " .. ID) -- This does not print, whatsoever.
				else -- This part fires on the output and reads all the "ID" (StringValue) that exists under Things (This part works. Don't worry about this.)
					print("This ain't it") -- This prints on the output
				end
			end
		end
		print(player.Name .. " purchased Gamepass " .. ID)	
	end
end)

change to:

if tonumber(g.Value) == ID then
1 Like

This solution worked! Thank you so much!

Why don’t you use an ‘IntValue’ object instead? That way the tonumber call won’t be necessary.