Can someone please tell me how can I detect if a player bought a specific gamepass?
Does it work in a LocalScript or in a Script? I used it in both and it doesn’t work:(
use a if statement, it’s a boolean. you can use a local script and a server script
You should be able to use UserOwnsGamePassAsync on both the server and client. What does your code look like?
I used it in both and it doesn’t work
In the localscript:
local MS = game:GetService("MarketplaceService")
local button = script.Parent
local Player = game.Players.LocalPlayer
local GamepassID = 228335926
button.MouseButton1Click:Connect(function()
MS:PromptGamePassPurchase(Player, GamepassID)
if MS:UserOwnsGamePassAsync(Player.UserId, 228335926 ) then
button:Destroy()
end
end)
in the script
game.Players.PlayerAdded:Connect(function(plr)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 228335926) then
print("hi")
end
end)
TheDevKing?
[30leetersblahblah][
Alright, thanks! But do you know why does my script not work?
Your server script works fine as intended. Have you tried adding an else condition if the user does not own the gamepass?
game.Players.PlayerAdded:Connect(function(plr)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 228335926) then
print("User owns gamepass")
else
print("User does not own gamepass")
end
end)
I’ll try it out now.
edit: yea i did. it printed out " User does not own gamepass " once i joined the game.
i think because i removed the gamepass from my inventory to test the purchase
it’s a test purchase, not a real purchase. is that the reason why it isn’t working?
Check your inventory again and choose a gamepass that you have owned and it should work.
Alright I’ll try it out and see if it works
oh yea so when the playerowns gamepass is called it checks to see if the player JOINED with the gamepass in their inventory. if they bought it inside of the experience they have to rejoin. there is some help
When the player buys a gamepass, does it automatically go their inventory? Well, I want to make it that if the player bought the gamepass, and it is in their inventory, the buy button becomes invisible. I wrote a code for that in a LocalScript. Should that code work:
local MS = game:GetService("MarketplaceService")
local BuyButton = script.Parent
local Player = game.Players.LocalPlayer
local GamepassID = 228335926
local MS = game:GetService("MarketplaceService")
BuyButton.MouseButton1Click:Connect(function()
MS:PromptGamePassPurchase(Player, GamepassID)
end)
if MS:UserOwnsGamePassAsync(Player.UserId, 228335926 ) then
BuyButton.Visible = false
else
BuyButton.Visible = true
end
I think, I don’t know. I might have to dig in more of MarketplaceService for you. A couple days or some hours i’ll see what’s up.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.