How to Make a VIP Tool (Gamepass) inside of Tool Shop?

Hello There! i’m a new programmer and i really need help with VIP Tool Gamepass inside of a tool shop that i made, the issue is the GUI TextButton “Buy” based on the value of “ItemName,ItemPrice” and these are “StringValue,IntValue” inside of parts in the MainShop
and i want to, when it comes to the VIP Tool when u click on the TextButton “Buy” it shows buy gamepass message.

Here's a Screen Shot

Here’s the Button and the Value
Note: this is screen shot in studio not ingame and i typed those values aka “Price, Eggs”
vipPan

Here's the buy script

this script run for Each tool not only the VIP one

local serverscriptService = game:GetService("ServerScriptService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local workSpace = game:GetService("Workspace")

local Settings = require(serverscriptService:WaitForChild("SettingSS"))
local DataStore = game:GetService("DataStoreService")

replicatedStorage:WaitForChild("ShopBuyA").OnServerEvent:Connect(function(player,page)
	local char = player.Character
	local shop = workSpace:WaitForChild("ToolShop")
	local currency = player:WaitForChild("leaderstats"):WaitForChild(Settings.Currency)
		if currency.Value >= shop:WaitForChild("Parts"):WaitForChild("Tool"..page):WaitForChild("ItemPrice").Value then
	player:WaitForChild("ToolSave"):WaitForChild("Tool"..page).Value = true
	for i,v in pairs(workSpace:WaitForChild("ToolShop"):WaitForChild("Parts"):GetChildren()) do
		local data = DataStore:GetDataStore(v.Name)
		local toolsave = player:WaitForChild("ToolSave"):WaitForChild(v.Name)
		data:SetAsync(player.UserId, toolsave.Value)
	end
	currency.Value = currency.Value - shop:WaitForChild("Parts"):WaitForChild("Tool"..page):WaitForChild("ItemPrice").Value
	end
end) 

Note : i already have the gamepass_id and i know how to make a gui Button gamepass, but idk how to make one inside of shop, and dont worry about equip/unequip cuz i already have script for this.

regards
xStaRz2

1 Like

For this you’ll need to use MarketplaceService’s PromptGamePassPuchase and the event PromptGamePassPuchaseFinished.

Here’s an example of the 2:

local mps = game:GetService("MarketplaceService")
local gamepassId = 12345


--prompting the purchase, you'll need the player obviously
mps:PromptGamePassPurchase(player, gamepassId)
--[[ now we need to wait until they choose, 
this event can fire for other gamepasses or players so we'll need to add some if statements. ]]
local connection do
    connection = mps.PromptGamePassPurchaseFinished:Connect(function(plr, id, didBuy)
        if plr.UserId == player.UserId then
            if didBuy then
                 --Here they did, give the tool
            else
                --Here they didn't buy
            end
            connection:Disconnect() --we don't need to connect anymore, lets free up memory
        end
    end)
end

Here’s some documentation on them:

1 Like

thats not the issue to me, the problem is The text buy works on each tool “that u can buy with game currency” not only for the vip 1 that i want to make it with robux or have the vip gamepass to equip, i can script 1 specific button to buy the gamepass but i’ve never done thing like this before i mean the vip tool in shop

Ah I see, my bad.
You’ll want to use UserOwnsGamePassAsync to check if they have the GamePass, it returns a bool if they do or not.

local mps = game:GetService("MarketplaceService")
local doTheyOwn = mps:UserOwnsGamePassAsync(player.UserId, gamepass_id)
--it'll be true or false if they do.
2 Likes