I have a VIP gamepass and one of the perks is you get given 500 Cash. However I want this to be a 1 time thing, so how can I do this as I can’t just do
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, PassID)
-- Give cash
end
As a player could just continuously leave and rejoin. Another problem is if the player buys the pass in game. I don’t want them to have to leave and rejoin to get the cash.
I could create a data point, however I don’t really wanna waste a whole data point just for this 1 check.
I would suggest using a DataStore for this, but if you want to avoid that, I guess an alternative could be to award a badge to the player after purchasing the game pass? You could check if the player owns the badge and if they don’t, award the badge and the cash.
Also, this is a really bad suggestion, and don’t even know if it still works or is accessible, but I believe the old Data Persistence API still exists? Perhaps this could be used; at least until it stops working or is removed completely?
if (Player:WaitForDataReady()) then
if (not Player:LoadBoolean("BoughtGamePass")) then
-- award cash
end
end
It’s deprecated. I would rather use DataStoreService to save and load player data for new work. When roblox completely removes the deprecated method you possibly have to give the players the cash again with the newer method because you can no longer access the data if roblox removes the deprecated method.
cc: @EmeraldLimes
Technically, you could use a developer product for a one time purchase, but it wouldn’t work for your use case, as you’d still have to store the fact that they’ve already purchased the product in a DataStore, so you can disable purchasing it again.
@CodeProto that’s why I said it was a really bad idea. I really wouldn’t recommend using deprecated methods for this reason exactly.
Problem with a developer product is I can’t have it show on the Roblox page, where I believe most gamepass purchases are made (atleast I buy all my gamepasses from the site, not in game, idk about everyone else)
I personally prefer to purchase game passes via the game itself, but this is largely due to the fact that I generally like to play Roblox on mobile, and that game passes are hidden in a separate menu on game pages in the app.
In all honesty, I think a badge fits your criteria best. It’ll cost you ⬢100 to upload the badge, but at least you won’t have to use DataStores. But just remember, Players can delete badges from their inventory. You know some players will abuse this in order to get unlimited cash, and there’s nothing you can do about this without using DataStores.
Like the first reply said you can easily use a badge as a way to determine if the player already got the cash or not, or you could use datastores (assuming you have the data set as a table then just add a “isVIP” key and set the value to true that way you don’t have to check if they own the gamepass again nor do you have to check if you already awarded them since if you did the isVIP will be true).
So It’ll be like this :
local myData = getPlayerData()
if myData.isVIP then
-- vip stuff (don't give the cash)
else
-- check if they own the gamepass, if they do set the isVIP to true and award them the cash since they bought from the game page
end
And to give them the cash once they bought then use :
local marketPlace = game:GetService("MarketplaceService")
marketPlace.PromptGamePassPurchaseFinished:Connect(function(player,gamepassId,bought)
if not bought then return end -- didn't buy
-- check if the gamepassid is the same as vip and give the cash + set isVIP to true
end)
EDIT : Forgot the mention, sorry for the error on my part, you do still have to check if they own the gamepass or not because if they do and isVIP is not true then they did not get the cash meaning they bought from the game page so check for that aswell.