Parallaxox

Security Door

Apr 15th, 2025
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. --https://youtu.be/UvbKl7cMRTE
  2. local door = script.Parent
  3. local allowedPlayers = {"ParallaxX", "Player2"} -- Replace with actual usernames
  4. local proximityDistance = 8 -- Distance to detect players near the door
  5. local currentlyAllowedPlayer = nil -- Stores the player currently using the door
  6.  
  7. game:GetService("RunService").Heartbeat:Connect(function()
  8.     for _, player in pairs(game.Players:GetPlayers()) do
  9.         local character = player.Character
  10.         if character and character:FindFirstChild("HumanoidRootPart") then
  11.             local distance = (character.HumanoidRootPart.Position - door.Position).Magnitude
  12.  
  13.             if distance < proximityDistance and table.find(allowedPlayers, player.Name) and currentlyAllowedPlayer == nil then
  14.                 currentlyAllowedPlayer = player
  15.  
  16.                 local transparencyBefore = door.Transparency
  17.                 local canCollideBefore = door.CanCollide
  18.  
  19.                 door.Transparency = 0.5
  20.                 door.CanCollide = false
  21.  
  22.                 repeat
  23.                     task.wait()
  24.                 until (character.HumanoidRootPart.Position - door.Position).Magnitude > proximityDistance
  25.  
  26.                 door.Transparency = transparencyBefore
  27.                 door.CanCollide = canCollideBefore
  28.  
  29.                 currentlyAllowedPlayer = nil
  30.             end
  31.         end
  32.     end
  33. end)
  34.  
Advertisement
Add Comment
Please, Sign In to add comment