when a brick in workspace called 'gss' is touched, it is supposed to prompt the touched to buy a gamepass or make a gui that says s/he already owns it.
this is a LOCAL SCRIPT in STARTERPACK
-- Localscript
repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character
local player = game.Players.LocalPlayer
local character = player.Character
local block = game:GetService'Workspace':WaitForChild("gss")
local debounce = false
block.Touched:connect(function(p)
if debounce then return end
debounce = true
-- This code can be within a 'LocalScript' object
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamePassID = 3682933 -- Change this to your game pass ID
-- Function to prompt purchase of the game pass
local function promptPurchase()
local player = Players.LocalPlayer
local hasPass = false
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
end)
if not success then
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass == true then
player.PlayerGui.owned.Text.Visible = true
wait(3)
player.PlayerGui.owned.Text.Visible = false
-- Player already owns the game pass; tell them somehow
else
MarketplaceService:PromptGamePassPurchase(player, gamePassID)
-- Player does NOT own the game pass; prompt them to purchase
end
local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess)
if purchaseSuccess == true and purchasedPassID == gamePassID then
print(player.Name .. " purchased the game pass with ID " .. gamePassID)
player.Character.Humanoid.Health.Value = 0
player:LoadCharacter()
-- Assign this player the ability or bonus related to the game pass
--
end
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)
end
debounce = false
end)
