I've been coding a gamepass button on my game, but i can't find a way to fix the syntax errors as i am a new coder. can somebody please help with the syntax errors?
local button = script.Parent local function onButtonActivated(local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local gamePassID = 22453139 s local function promptPurchase() local player = Players.LocalPlayer local hasPass = false local success, message = protocall(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 then message (You already own this pass) else MarketplaceService:PromptGamePassPurchase(player, gamePassID) end end) print("Button activated!") end button.Activated:Connect(onButtonActivated)
I'm not sure if this would work but I tried
local button = script.Parent local function onButtonActivated() local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local gamePassID = 22453139 local function promptPurchase() local player = Players.LocalPlayer local hasPass = false local success, message = protocal(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 then message ("You already own this pass") else MarketplaceService:PromptGamePassPurchase(player, gamePassID) end end print("Button activated!") end button.Activated:Connect(onButtonActivated)