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

How to make a open/close Text button GUI into a gamepass ?

Asked by
bossaeed2 -50
6 years ago

So this is what i mean by it. Is like when you click on the button it asks you to buy the gamepass before getting into the GUI then it opens.

I tried my best but this is my result

https://gyazo.com/01eaf3905aa7503fc398f35e968728c8

Script that i made

script.Parent.MouseButton1Down:connect(function() script.Parent.Parent.Frame.Visible = not script.Parent.Parent.Frame.Visible end) local player = game.Players.LocalPlayer local id = 884659792 game:GetService("MarketplaceService"):promptPurchase(player, id) end)

0
nice block code :D greatneil80 2647 — 6y
0
first make another gui and put the gamepass code in that gui's text button greatneil80 2647 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You have already asked this question before, and I have already answered it. You can find the question right here -- However, here is a more updated code, because now I know where your buttons are located so that I can make the entire script. For guidance, go to my previous answer. Here is the same code as last time, but completed because I know where the frame is:

-- local script inside the button
local allow = false
local Player = game.Players.LocalPlayer
if game.MarketplaceService:PlayerOwnsAsset(Player,773709832) then -- checks if he has it, again, replace the id
    allow = true -- sets a variable to true
end
--( they will have to reset after purchasing the gamepass)
script.Parent.MouseButton1Down:Connect(function()
    if allow then-- if they have it, do which ever you want
script.Parent.Parent.Frame.Visible = true -- here is your new line.
    else -- if they do not have it, ask them to purchase
        game.MarketplaceService:PromptPurchase(Player, 773709832) -- change the number to the ID of the gamepass, found in its link of your gamepass
    end
end)

0
Ok Thanks. This really helped me, it did a lot! But when i click in the Gui button it doesnt close any idea ? bossaeed2 -50 — 6y
0
never mind, I made it my self script.Parent.Parent.Frame.Visible = not script.Parent.Parent.Frame.Visible bossaeed2 -50 — 6y
0
mhm. I thought an x button might be in your gui. If you want me to make it close as well, I could do that iamnoamesa 674 — 6y
Ad

Answer this question