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

How can I make a part give open a shop on touch?

Asked by 10 years ago

I have a VIP door with a gamepass. I would like to know how I can make that door detect if a player does not have the gamepass and pop up a GUI to buy the pass.

Thank you!

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

Here you go. Simple events and methods.

id = 1337 -- gamepass id

script.Parent.Touched:connect(function(hit)
    if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
        p = game.Players:GetPlayerFromCharacter(hit.Parent)
        if game:GetService("GamePassService"):PlayerHasPass(p, id) then
            script.Parent.CanCollide = false
            script.Parent.Transparency = 0.7
            wait(0.2)
            script.Parent.Transparency = 0
            script.Parent.CanCollide = true
        else
            game:GetService("MarketplaceService"):PromptPurchase(p,id)
        end
    end
end)
Ad

Answer this question