Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Struggling with Syntax errors on a gamepass button, can i please have help?

Asked by 3 years ago

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)
0
I have found a few fixes to my own code, such as ("You already own this pass") instead of the one missing the parenthasis CreamySamoyed 2 — 3y

1 answer

Log in to vote
0
Answered by
uf5m 15
3 years ago

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)
0
thank you so much CreamySamoyed 2 — 3y
Ad

Answer this question