Check if owner owns gamepass in Roblox Studio

Can I check if Roblox Studio if I have bought my gamepass?

I’m trying to make 2 gamepasses that gives you some item (sword) when buyed.
The thing is: When I buy it, and then rejoin the session (Im on roblox studio. Just press “Close” and then “Play” again), the game just forgets that purchase as I’ve never purchased it before. And I dont want to spend robux to check if each item is working fine…

I know that there is a UserOwnsGamePassAsync function but as I’ve said it returns false for me like I’ve never purchased certain item before.

Is it possible to check if I own a gamepass in Roblox Studio?

1 Like

The thing is its a test purchase, it doesn’t save the purchase, I don’t think atleast.
You should make a datastore for your items where you store the purchased items.

local DataStoreService = game:GetService("DataStoreService")
local ItemDataStore = DataStoreService:GetDataStore("Items")
game.Players.PlayerAdded:Connect(function(Player)

local PurchasedItems= Instance.new("Folder", Player) --or You can make it a table PurchasedItems{}
PurchasedItems.Name = "Items"
local ItemData = ItemDataStore:GetAsync(Player.UserId)
game.Players.PlayerRemoving:Connect(function(Player)
	local SaveData =  {}
	for _,Child in pairs(Player.Items:GetChildren())do
		table.insert(SaveData,Child.Value)

ItemDataStore:SetAsync(Player.UserId, SaveData)
end)









end)

also this is not a good datastore I recommend tutorials on advanced ones

1 Like

But the roblox should remember the purchase from UserOwnsGamePassAsync function.
Going to the published game wont work since I have to paid for the gamepass

Instead of using UserOwnsGamepassAsync make a list of players (using their UserIds) that stores all the players you want to have the game pass, I believe that’s how gamepass gifting works.

It would look like this, have this function:

local MSS = game:GetService("MarketPlaceService")
local playersWithGamepass = {
    111111 = {
        111111 -- Game pass ids here 
    }
} -- Add user ids here

function ownsGamepass(userId,gamepassId)
    if MSS:UserOwnsGamepassAsync(userId, gamepassId or table.find(playersWithGamepass then
        local usersGamepasses = playersWithGamepass[userId]
    if table.find(usersGamepasses, gamepassId then return true end
    end
    return false
end

-- Use:
game.Players.PlayedAdded:Connect(function(player)
    local gamepassId = 111111 --Gamepass ID here
    local owns = ownsGamepass(player.UserId, gamepassId)
    if owns then
        print("Owns")
    else
        print("Doesn’t own")
    end
end)
1 Like

Yeah it should, in the real game atleast, it works in the real game, not in the test since you don’t actually own it

1 Like

or just use that other method where you store them(owned items) in a table and just save the table

1 Like

sadge :sob:

Also making a datastore for it is unnecessary I think. I know I can use it for giving gamepasses without the gamepass prompt but Im not gonna use it.

or can I somehow give gamepass (the gamepass itself) to myself as the owner if I removed it from my inventory?

you dont specifically need a datastore for gamepasses , but if it is a devproduct then probably yes

1 Like

You can use what I gave you in my previous reply

1 Like

In the script of giving the gamepass owner the gamepass thing you can make OR if player userid is yours then it does what the gamepass does to others who own the gamespass, but for you you don’t need it you just have to be you

1 Like

Its not what I want but thanks.

I wanted to give myself a gamepass itself. Like an item in a roblox library (https://www.roblox.com/game-pass/gamepassID)

Wdym, if you put your userId in the table with the gamepassIds it’ll work, this will also work for anyone, say you were to make gamepass gifting

Edit:
Oh, well I don’t think that is possible.

1 Like

Just use Or if the player is you then it gives the item in with the Or statement in the function where the player recieves the gamepass perks

1 Like

if I disable “Item for Sale”, would it work for free or would it just show the info that the gamepass is not accessible?

No, then it just isn’t for sale

2 Likes

Like what @grandisy said, it would say it’s not for sale, my method would actually still work even if it’s not for sale anymore.

1 Like

I know what you’re saying. If I wanted to give myself an item itself then sure I’d use that method but I actually want to give myself a gamepass itself. And we agreed there is no way to do that without paying ;c

1 Like

that table would probably need to save actually, but @TracerBH I suggest the or if Player.UserId = --your userid if you just want yourself to have it aswell as the gamepass owners, that is what is the easiest solution for your problem It doesn’t give you the gamepass , but it literally gives the same perks so its the same thing except you don’t own the roblox gamepass asset, but that doesn’t really matter since you are the owner and you make the rules of you experience

1 Like

Yeah, real gamepass gifting doesn’t exist sadly. I’m pretty sure that the only way to do it is to make your own script

1 Like