Advertisement
HowToRoblox

VIPDoorHandler

Oct 10th, 2020
4,185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. local plr = game.Players.LocalPlayer
  2.  
  3. local char = plr.Character or plr.CharacterAdded:Wait()
  4. local humanoid = char:WaitForChild("Humanoid")
  5.  
  6.  
  7. local mps = game:GetService("MarketplaceService")
  8.  
  9. local gamepassID = 12178123
  10.  
  11.  
  12. local gamepassOwned = false
  13.  
  14. pcall(function()
  15.    
  16.     gamepassOwned = mps:UserOwnsGamePassAsync(plr.UserId, gamepassID)
  17. end)
  18.  
  19.  
  20. if gamepassOwned == true then
  21.    
  22.     workspace.VIPDoor.Transparency = 0.5
  23.     workspace.VIPDoor.CanCollide = false
  24. end
  25.  
  26.  
  27. humanoid.Touched:Connect(function(touchedPart)
  28.    
  29.     if gamepassOwned == true then return end
  30.    
  31.    
  32.     if touchedPart == workspace.VIPDoor then
  33.        
  34.        
  35.         mps:PromptGamePassPurchase(plr, gamepassID)
  36.     end
  37. end)
  38.  
  39.  
  40. mps.PromptGamePassPurchaseFinished:Connect(function(playerPurchased, purchasedID, purchaseSuccess)
  41.    
  42.     if not purchaseSuccess then return end
  43.    
  44.     if playerPurchased == plr and purchasedID == gamepassID then
  45.        
  46.        
  47.         gamepassOwned = true
  48.        
  49.        
  50.         workspace.VIPDoor.Transparency = 0.5
  51.         workspace.VIPDoor.CanCollide = false
  52.     end
  53. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement