Ok So I’m trying to make a couple of 2x gamepasses. After testing, I realized that everyone was starting off with the 2x gamepasses even without buying it. I made a brand new Roblox account to test. On the storepage, it prompts him to purchase the gamepasses, so he should have nothing. But once i enter my game, he has the game passes. I made a button to test the results of UserOwnsGamePassAsync and it is returning true. There’s alot of code, So I’ll post the important ones.
I was testing if pcall made a difference, thats why there’s one with it and the rest without. Here’s my pcall function
function UserOwnsGamePassAsync(PlayerID,GamePass)
local Success,Results = pcall(function()
return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(PlayerID,GamePass)
end)
print(Success,Results)
if Success and Results then
return true
end
end
Here’s the prompt to purchase, just incase theres something wrong there. But I like, my tests have the player start witht he game passes even without touching the prompt
local gamepassID = 22504732
script.Parent.MouseButton1Click:Connect(function()
game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer,gamepassID)
end)
I’m not sure, but I believe the Results variable on the call is the error that will be thrown if the pcall fails. Try removing the Results from the if statement after the pcall
function UserOwnsGamePassAsyncM(PlayerID,GamePass)
local Success = pcall(function()
return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(PlayerID,GamePass)
end)
print(Success)
if Success then
return
end
end
I removed the “results” variable and I renamed the pcall function just to make sure it doesn’t interfere with the actual UserOwnsGamePassAsync. Whats weird is that I have gamepasses with Tools and they work fine. Its only my 2x Gamepasses that are doing this
function UserOwnsGamePassAsync(PlayerID,GamePass)
local Success, Result = pcall(function()
return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(PlayerID,GamePass)
end)
print(Success)
if Success and Result == true then
return Result
end
end
I don’t know if my explanation is correct, but when using a wrapped call of a function with the intention of getting the result of methods within the pcall, perhaps creating an upvalue within the UserOwnsGamePassAsync function and then setting it if the game pass check succeeds to that upvalue as listed below:
function UserOwnsGamePassAsync(PlayerID,GamePass)
local ownsPass; -- Make sure that this variable represents the result of the gamepass check, NOT Success OR err ----
local Success,err = pcall(function()
ownsPass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(PlayerID,GamePass)
end)
if Success then
return ownsPass --- Return the result of the variable
else return false, err end --- Can be returned in the desired format/order
end
print(UserOwnsGamePassAsync(665958081,20767517))
I noticed that directly trying to read from the contents of Success and Err doesn’t work so I resort to using a separate variable that changes IF success is true.
Ok, I solved my problem, It was my stupid mistake. I forgot “.Value” after many of the variables so it was always reading true even though UserOwnsGamePassAsync was sending false. Thank you everyone for your help