Advertisement
hellom38

Example Lua

Jul 10th, 2022
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. --Door that needs a key to open
  2. local part = script.Parent
  3.  
  4. local wall = game.Workspace.Wall
  5.  
  6. local canOpen = true
  7.  
  8.  
  9.  
  10. local function lift(otherPart)
  11.  
  12. local partParent = otherPart.Parent
  13.  
  14. local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
  15.  
  16. if humanoid and canOpen then
  17.  
  18. local player = game.Workspace:FindFirstChild(partParent.Name)
  19.  
  20. if player then
  21.  
  22. if player:FindFirstChild('Key') then
  23.  
  24. canOpen = false
  25.  
  26. wall.Transparency = 1
  27.  
  28. wall.CanCollide = false
  29.  
  30. local key = player:FindFirstChild('Key')
  31.  
  32. key.Parent = game.Workspace
  33.  
  34. key.Handle.Position = Vector3.new(math.random(x1,x2),5,math.random(z1,z2))
  35.  
  36. wait(2)
  37.  
  38. wall.Transparency = 0
  39.  
  40. wall.CanCollide = true
  41.  
  42. canOpen = true
  43.  
  44. end
  45.  
  46. end
  47.  
  48. end
  49.  
  50. end
  51.  
  52.  
  53.  
  54. part.Touched:Connect(lift)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement