AlexYT_2011

Badge Door

Jan 3rd, 2023 (edited)
976
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | Gaming | 0 0
  1. local BS = game:GetService("BadgeService")
  2. local Badge = 2130281077 -- The ID of the Gamepass.
  3. local OpenTime = 1 -- The time the door is open for.
  4. local OpenTrans = 0.5 -- The transparency of the door when it is open.
  5. local CloseTrans = 0 -- The transparency of the door when it is closed.
  6. local BuyGUI = false -- Set to false to stop the BuyGUI appearing.
  7. local KillOnTouch = true -- Set to false to stop players being killed when they touch it.
  8. local Whitelist = {
  9.     1
  10. } -- USERID || People that can open the door without owning the badge.
  11.  
  12. -----------------------------------------------------------------------------------------------
  13.  
  14. local Door = script.Parent -- The door
  15.  
  16. -----------------------------------------------------------------------------------------------
  17.  
  18. function CheckWhitelist(v)
  19.     for i = 1, #Whitelist do
  20.         if v == Whitelist[i] then
  21.             return true
  22.         end
  23.     end
  24.     return false
  25. end
  26.  
  27. Door.Touched:Connect(function(hit)
  28.     if game.Players:GetPlayerFromCharacter(hit.Parent) then
  29.         local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
  30.         if Badge <= 0 then return nil end
  31.         if BS:UserHasBadgeAsync(plr.UserId, Badge) or CheckWhitelist(plr.UserId) then
  32.             Door.CanCollide, Door.Transparency = false, OpenTrans
  33.             wait(OpenTime)
  34.             Door.CanCollide, Door.Transparency = true, CloseTrans
  35.         else
  36.             Door.CanCollide, Door.Transparency = true, CloseTrans
  37.             if BuyGUI == true then
  38.                 BS:PromptGamePassPurchase(plr, Badge)
  39.             end
  40.             if KillOnTouch == true then
  41.                 plr.Character.Humanoid.Health = 0
  42.             end
  43.         end
  44.     end
  45. end)
Advertisement
Add Comment
Please, Sign In to add comment