#Gui Gamepass problem need help !

1 messages · Page 1 of 1 (latest)

south monolith
#

show us the script

coarse shoal
#

the script in the serverScriptService ```local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")

local GAMEPASS_ID = 1587483315 -- Bomb gamepass ID
local RequestBombTool = ReplicatedStorage:WaitForChild("RequestBombTool")
local C4Tool = ReplicatedStorage:FindFirstChild("C4")

RequestBombTool.OnServerEvent:Connect(function(player)
if not C4Tool then
warn("C4 tool not found in ReplicatedStorage")
return
end
local owns = false
local success, err = pcall(function()
owns = MarketplaceService:UserOwnsGamePassAsync(player.UserId, GAMEPASS_ID)
end)
if not success then
warn("Error checking gamepass ownership: " .. tostring(err))
return
end
if owns then
-- Only give if player doesn't already have it
local backpack = player:FindFirstChild("Backpack") or player.Backpack
if backpack and not backpack:FindFirstChild("C4") then
local toolClone = C4Tool:Clone()
toolClone.Parent = backpack
print("C4 tool given to player: " .. player.Name)
else
print("Player already has C4 or backpack not found: " .. player.Name)
end
else
print("Player does not own the gamepass: " .. player.Name)
end
end)

#

the local script in the button ```local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer

local GAMEPASS_ID = 1587483315 -- Correct Bomb gamepass ID
local RequestBombTool = ReplicatedStorage:WaitForChild("RequestBombTool")
local button = script.Parent

local function checkAndGiveC4()
local owns = false
pcall(function()
owns = MarketplaceService:UserOwnsGamePassAsync(player.UserId, GAMEPASS_ID)
end)
if owns then
RequestBombTool:FireServer()
end
end

button.MouseButton1Click:Connect(function()
MarketplaceService:PromptGamePassPurchase(player, GAMEPASS_ID)
end)

-- Listen for purchase completion and give tool instantly if successful
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(userId, gamePassId, wasPurchased)
if userId == player.UserId and gamePassId == GAMEPASS_ID and wasPurchased then
RequestBombTool:FireServer()
end
end)

-- Also check ownership when player joins (in case they already own it)
checkAndGiveC4()

#

@south monolith

slender matrix
#

What is it failing at?