i have this boombox tool that i’m using for the gamepass in my city game, and i’m thinking about making a script where you would automatically get the tool after you purchase the gamepass
there were youtube videos talking about gamepass tool buttons, but the problem was you would have to rejoin to get the gamepass when you’re in the game
the good news is there is one video similar to what i was talking about Roblox | How to make a Gamepass Gear Script | 2019 [FE] - YouTube, but unfortunately the video was 3 years ago, and filteringenabled doesn’t exist anymore
could someone help me with this and tell me what to do to make my button give someone the tool once they purchase the gamepass
hopefully this probably makes sense
btw im not really that much of a scripter person so i might not know stuff like connect(function() or whatever those are
PromptGamePassPurchaseFinished. About as simple as that. You’re welcome to implement additional strategies to make sure players get their items upon respawns or similar, such as caching the player’s purchase or placing it into their StarterGear (as simple examples).
You would have to insert the tool into the player’s backpack, here is a sample script I made:
local gamepassId = -- Your gamepass ID here
local marketplaceService = game:GetService("MarketplaceService")
local tool = -- Your tool path
marketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamepId, wasPurchased)
if wasPurchased and gamepId == gamepassId then
local newTool = tool:Clone()
newTool.Parent = player.Backpack
end)
I haven’t tested it but let me know if you are getting any errors.
No, the page just includes a code sample of how you can use PromptGamePassPurchaseFinished. It’s up to you to determine how to customise the connected function to give the user a tool.
The Developer Hub has many articles and reference pages you can scroll through to learn or understand how to accomplish some things. There are some coding tutorials and documentation of API there but then the other half is doing problem solving by applying what you know or have learned in order to create the system you’re looking for.
It, along with the toolbox, have good materials if you’re looking to dive into programming or get a reference for how some things may be accomplished.
i am still confused since i’m not a scripter but i can ask you this
do you know how to make something like this Roblox | How to make a Gamepass Gear Script | 2019 [FE] - YouTube but a little updated, because that’s what i’m trying to make for my gamepass button to work whenever someone purchases the gamepass and then it gives them the tool if you know what i mean
I can’t provide you all the code but I can lead you in the correct direction.
--Client
local MarketPlaceService = game:GetService("MarketplaceService")
local Player = game.Players.LocalPlayer
MarketPlaceService:PromptGamePassPurchase(Player, 999999) --Player, GamepassId (The one in the URL)
--Server
local MarketPlaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Tool = ReplicatedStorage:WaitForChild("SomeTool")
MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(Player, Id, Purchased)
if Id == 999999 then --The gamepass Id
if Purchased then
print(Player.Name.. " purchased a tool!")
local Tool = Tool:Clone() --Create new tool for the player
Tool.Parent = Player.Backpack
end
end
end)