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

how to make a shop textbutton a whole Gamepass ? [closed]

Asked by
bossaeed2 -50
7 years ago

so basically i made a shop gui that has things like spaws gears and other random things. So i tried so hard to make that shop a gamepass. Like example when i click on the shop i need it to be a gamepass. I tried but i couldnt do that. Can someone help me ?

Closed as Not Constructive by Goulstem

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 7 years ago

This is not a request site, so please include a script in which you have tried before, so that we may look at it and correct it. That would help you achieve your goal, help you understand what you did, and be more understandable for anyone viewing this later. Anyways, I'll explain how you would go about this. Firstly, you need to know about PromptPurchase. This is a built in function for local scripts, that will give the player the prompt. So, if you wanted your shop to simply ask them to purchase the gamepass, it would look like this:

-- local script inside the button
local Player = game.Players.LocalPlayer
script.Parent.MouseButton1Down:Connect(function()
    game.MarketplaceService:PromptPurchase(Player, 773709832) -- change the number to the ID of the gamepass, found in its link
end)

Now, this poses one issue. After they purchase it, if they click it, it will still prompt them it! So that means we must use PlayerOwnsAsset. This is another built in function that can check if the player has the asset. So the local script would need to include the following:

local allow = false
if game.MarketplaceService:PlayerOwnsAsset(Player,773709832) then -- checks if he has it, again, replace the id
    allow = true -- sets a variable to true
end

This local script will run every time the character spawns. Now, we must connect the codes.

-- 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
script.Parent.MouseButton1Down:Connect(function()
    if allow then-- if they have it, do which ever you want
        --execute code. Give them weapons or open admin commands, whatever you want.
    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
    end
end)

Simply put what you wish to happen when they click it after they purchased the pass, in the block that says 'execute code', and change the IDs. I hope I helped :)

0
please accept the answer if I helped iamnoamesa 674 — 7y
0
but the shop doesnt pop up after buying the gamepass bossaeed2 -50 — 7y
0
In the part where I said execute code, make the shop visible. Would look something like: script.Parent.Parent.Shop.Visible = true iamnoamesa 674 — 7y
0
still not workin bossaeed2 -50 — 7y
Ad