UserOwnsGamepassAsync: Parsed invalid JSON error

  1. What do you want to achieve?
    I would wish for my tycoon cash balance to continually increase with new players joining.

  2. What is the issue?
    I have a tycoon kit which continually increases cash in a while wait(3) do loop. After testing in studio and finding that it all works, I have done a test launch and found a pretty major issue. The issue is that the cash is not being given to the collection spot (mailbox in this case). Upon first joining the mailbox will continually be filled with cash and it is not until older servers appear that the issue arises. After looking at the console, I have discovered a rather large error. I have linked an image of it below along with the snippet of code it is referring to.
    (line 226 states the following: script.Parent.CashCollect.Value = script.Parent.CashCollect.Value + script.Parent.Income.Value)

  3. What solutions have you tried so far?
    I have wrapped the whole loop in a pcall function in the hopes that it would just run through the error, but it does not seem like that is the case. I looked for various solutions to my problem and found none.

while wait(3) do
	pcall(function()
		if script.Parent.Owner.Value ~= "None" then
			local Player = game.Players:FindFirstChild(script.Parent.Owner.Value)
			if Player then
				if (Player and Player:FindFirstChild("InfiniteMailbox")) or (Player and game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId,10518526)) then
					script.Parent.MaxHold.Value = 9e9
				end
				if script.Parent.CashCollect.Value < script.Parent.MaxHold.Value then
					script.Parent.CashCollect.Value = script.Parent.CashCollect.Value + script.Parent.Income.Value
					if (Player and Player:FindFirstChild("x2Cash")) or (Player and game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId,10398126)) then
						script.Parent.CashCollect.Value = script.Parent.CashCollect.Value + script.Parent.Income.Value
					end
					if script.Parent.CashCollect.Value >= script.Parent.MaxHold.Value then
						Full = true
						script.Parent.CashCollect.Value = script.Parent.MaxHold.Value
						script.Parent.Essential.Mailbox.CollectSpot.BillboardGui.Holding.TextColor3 = Color3.fromRGB(255,0,0)
					else
						Full = false
						script.Parent.Essential.Mailbox.CollectSpot.BillboardGui.Holding.TextColor3 = Color3.fromRGB(50, 255, 126)
					end
					script.Parent.Essential.Mailbox.CollectSpot.BillboardGui.Holding.Text = "$" .. script.Parent.CashCollect.Value .. "/" .. script.Parent.MaxHold.Value
				end
				if Player then
					game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("MailboxAnimation"):FireClient(Player,script.Parent.Essential.Mailbox,script.Parent.Income.Value,Full)
				end
				if Player:FindFirstChild("AutoCollect") or game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId,10520087) then
					local CashDataStore = DataStore2("Cash",Player)
					CashDataStore:Set(Player.leaderstats.Cash.Value + script.Parent.CashCollect.Value)
					script.Parent.CashCollect.Value = 0
					script.Parent.Essential.Mailbox.CollectSpot.BillboardGui.Holding.Text = "$" .. script.Parent.CashCollect.Value .. "/" .. script.Parent.MaxHold.Value
				end
			end
		end
	end)
end
2 Likes

hmmm, i think thats what i saw in a game…

1 Like

I too get this error for some reason…

After various amounts of testing, I have found that prompting UserOwnsGamepassAsync in a loop is causing this error. I advise that you hook it up to a PromptGamePassPurchaseFinished event and then create a variable or something of the like in which you can check for in the loop. This fixed the problem for me and I hope it will fix it for you as well!

1 Like