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

Is there something wrong with my gamepass prompt script?

Asked by 4 years ago

I made a script which, if a gamepass isn't owned, to prompt the player to buy it. I tested it out on a Roblox Studio server, but after I bought it and I tried to click the button the script is in, it still prompted me to buy it. I was wondering if this was an error in my script or if this will always happen when testing on a Roblox Studio server. Here's my script, located in a TextButton:

ms = game:GetService("MarketplaceService")

script.Parent.MouseButton1Click:Connect(function()
    if ms:UserOwnsGamePassAsync(script.Parent.Parent.Parent.Parent.Parent.UserId, 8885033) and script.Parent.Parent.Parent.Parent.Parent.Info.BonusMusic.Value == false then
        script.Parent.Parent.Parent.Parent.Parent.Info.BonusMusic.Value = true
        script.Parent.Text = "Yes"

    elseif ms:UserOwnsGamePassAsync(script.Parent.Parent.Parent.Parent.Parent.UserId, 8885033) and script.Parent.Parent.Parent.Parent.Parent.Info.BonusMusic.Value == true then
        script.Parent.Parent.Parent.Parent.Parent.Info.BonusMusic.Value = false
        script.Parent.Text = "No"

    elseif not ms:UserOwnsGamePassAsync(script.Parent.Parent.Parent.Parent.Parent.UserId, 8885033) then
        ms:PromptGamePassPurchase(script.Parent.Parent.Parent.Parent.Parent, 8885033)
    end
end)

(I'd view source since it doesn't seem fit correctly on the website)

0
try just using "else" instead of "elseif not" 0msh 333 — 4y
0
It still seems to happen NoahsRebels 99 — 4y

Answer this question