Pass Gioco

Gli utenti possono acquistare il pass gioco per sbloccare l'accesso permanente a contenuti e funzionalità esclusive, disponibili per tutta la vita.

Crea Pass Gioco

https://create.roblox.com/
>
Dashboard
>
Creations
>
My Experiences
>
[Your Game]
Image 1
Image 2
Roblox Studio
Passes
>
Create A Pass
>
[Enter Details]
>
Create Pass
Image 1
Image 2
Roblox Studio
Back to Game Pass Page
>
Click the Created Pass
>
Sales
>
[Enter Details]
>
Save Changes
Image 1
Roblox Studio
Back to Game Pass Page
>
Copy Asset ID
Image 1
Roblox Studio

Inizia Acquisto

local passID = YOUR_GAME_PASS_ID  
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

-- Next Slide: checkAndPromptPurchase(player)

game.Workspace:WaitForChild("PassCheck"):WaitForChild("SurfaceGui"):WaitForChild("Purchase").Activated:Connect(
    function()
        local player = Players.LocalPlayer
        checkAndPromptPurchase(player)
    end
)
	
local function checkAndPromptPurchase(player)
    local hasPass = false
    local success, message = pcall(function()
        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, passID)
    end)
    if not success then
        warn("Error while checking if player has pass: " .. tostring(message))
        return
    end
    if hasPass then
        -- Player already owns the Pass; you can display a message or take another action
        print("You already own the Game Pass!")
    else
        -- Player does NOT own the Pass; prompt them to purchase
        MarketplaceService:PromptGamePassPurchase(player, passID)
    end
end

Concedi Privilegio all'Acquisto del Pass Gioco

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local passID = YOUR_GAME_PASS_ID  

local function onPromptPurchaseFinished(player, purchasedPassID, purchaseSuccess)
	if purchaseSuccess and purchasedPassID == passID then
		-- logic for Game Pass
	end
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(userId, purchasedPassID, purchaseSuccess)
	local player = Players:GetPlayerByUserId(userId)
	if player then
		onPromptPurchaseFinished(player, purchasedPassID, purchaseSuccess)
	end
end)

Concedi Privilegio al Giocatore all'Ingresso

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local passID = YOUR_GAME_PASS_ID  

local function onPlayerAdded(player)
	local hasPass = false
	-- Check if the player owns the Game Pass
	local success, message = pcall(function()
		hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, passID)
	end)
	if not success then
		warn("Error checking pass ownership: " .. tostring(message))
		return
	end
	if hasPass then
		-- logic for Game Pass
	end
end

Players.PlayerAdded:Connect(onPlayerAdded)

Se hai trovato utile questo tutorial e desideri supportare il mio lavoro, considera di offrirmi un caffè.

Grazie mille per il tuo supporto!

Offrimi un caffè