You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to fix UserOwnsGamePassAsync not giving me true even though I have the gamepass.
What is the issue? Include screenshots / videos if possible!
Title, and when I created the gamepass, I was automatically given it as the group owner.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried looking on the developer forums, however none of them had a solution I could use.
This is like the code I’m using (Server Script):
local Enabled = false
RemoteEvent.OnServerEvent:Connect(function(Player)
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId,GamepassID) == true then
if Enabled == false then
Button.Text = "On"
Enabled = true
else
Button.Text = "Off"
Enabled = false
end
end
end)
local mps = game:GetService("MarketplaceService")
local owns = mps:UserOwnsGamePassAsync(plr.UserId, GamepassID)
if owns == true then
if Enabled == false then
Button.Text = "On"
Enabled = true
else
Button.Text = "Off"
Enabled = false
end
end
Unfortunately this didn’t solve my problem, and for clarification this error happens when I try to buy the gamepass… if I don’t own the gamepass according to UserOwnsGamePassAsync then why does this error say I have it… so confusing
I haven’t looked this through thoroughly yet, but could you add a print statement/debugging statement checking if it’s true/false/nil? It could help with debugging.
The remote event is being fired, this is confirmed by me being prompted the gamepass buy.
(I cut out the part in the code as I thought it wouldn’t be important)
This is my updated code:
RemoteEvent.OnServerEvent:Connect(function(Player)
local HasGamepass = false
local got,err = pcall(function()
HasGamepass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId,GamepassID)
end)
if HasGamepass then
if Enabled == false then
Button.Text = "On"
Enabled = true
else
Button.Text = "Off"
Enabled = false
end
else
MarketplaceService:PromptPurchase(Player,GamepassID,true)
end
end)