Dark_12400

Premium Script

Oct 24th, 2020
1,695
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local MarketplaceService = game:GetService("MarketplaceService")
  2. local Players = game:GetService("Players")
  3.  
  4. local teleporter = script.Parent
  5. local showPrompt = true
  6.  
  7.  
  8. local function onTeleporterTouch(otherPart)
  9.  
  10.  
  11.     local player = Players:GetPlayerFromCharacter(otherPart.Parent)
  12.     if not player then return end
  13.  
  14. -- If the user has Premium, then they will be teleported to the "EndLocation" part in the workspace
  15.     if player.MembershipType == Enum.MembershipType.Premium then
  16.         otherPart.Parent.HumanoidRootPart.CFrame = CFrame.new(workspace["EndLocation"].position)
  17. -- You can change (workspace["EndLocation"].position) to a specific location by using CFrame.new(Vector3.new(X, Y, Z))
  18.  
  19.     -- If they don't have premium, this prompts a Premium upgrade (use debounce to show it only once every few seconds)
  20.     else
  21.         if showPrompt == false then return end
  22.         showPrompt = false
  23.         delay(5, function()
  24.             showPrompt = true
  25.         end)
  26.         MarketplaceService:PromptPremiumPurchase(player)
  27.         warn("Prompted Premium purchase")
  28.     end
  29. end
  30. teleporter.Touched:Connect(onTeleporterTouch)
  31.  
  32. -- If needed, use this event to know when the Premium modal is closed
  33. MarketplaceService.PromptPremiumPurchaseFinished:Connect(function(player)
  34.     warn("Upsell modal closed")
  35. end)
RAW Paste Data