So I have a game, and I want to make it so whenever the player has a gamepass, a imagebutton appears. But for some reason, this isn't working. It worked yesterday, and I honestly don't know what the problem could be, so can someone please review it and tell me if they see any errors?
Server Log: 19:33:25: Marketplace::UserOwnsGamePassAsync: Parsed Invalid JSON. Data may be corrupted. Stack Begin Stack End
Script:
local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local LocalPlayer = game:GetService("Players").LocalPlayer local gamePassID = 4789729 -- Change this to your game pass ID function onPlayerSpawned(player) local hasPass = false -- Check if the player already owns the game pass local success, message = pcall(function() hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID) print("BHammer Appeared In Inv") end) -- If there's an error, issue a warning and exit the function if not success then warn("Error while checking if player has pass: " .. tostring(message)) return end if hasPass == true then LocalPlayer.PlayerGui:WaitForChild("Inventory").Frame.BHSignal.Visible = true end end game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function() onPlayerSpawned(player) end) end) -- Connect 'PlayerAdded' events to the 'onPlayerAdded()' function Players.PlayerAdded:Connect(onPlayerSpawned)
I am very, very, sorry for the stupidity of this. I had just transferred this game from a player creation, to a group creation, and thus the gamepasses In my old game wouldn't work. So I made new ones in the group game; But completely forgot that you wouldn't automatically obtain the gamepasses from a group game. So in the end, the error was I didn't have them purchased xD