OnFireRobloxScriptin

Keycard only Area/Wall

Aug 3rd, 2026
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. --//Services
  2. local Players = game:GetService("Players") --Variable for Players
  3.  
  4. --//Variables
  5. local wall = script.Parent --Variable for wall
  6.  
  7. --//Function
  8. wall.Touched:Connect(function(hit) --When wall is touched
  9.     if hit and hit.Parent:FindFirstChild("Humanoid") then --Check if its a player
  10.         local char = hit.Parent --Variable for character
  11.         local player = Players:GetPlayerFromCharacter(char) --Variable for character's Player
  12.         local backpack = player.Backpack --Variable for Player's backpack
  13.         if char:FindFirstChild("Keycard") or backpack:FindFirstChild("Keycard") then --Locate keycard in player or backpack
  14.             wall.CanCollide = false -- Allow player to go through wall
  15.             task.wait(1) --1 second wait
  16.             wall.CanCollide = true -- Make wall solid
  17.         end
  18.     end
  19. end)
Advertisement
Add Comment
Please, Sign In to add comment