Advertisement
irishWarlock89

Sliding Door Script

Jul 24th, 2024 (edited)
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | Source Code | 0 0
  1. --script requirements:
  2. ----a door part
  3. ----a transparent placeholder part where you want the door to move to when opening
  4. ------just duplicate the door, move it, and rename it
  5. ----2 buttons (inside and outside), and each with a proximity prompt
  6.  
  7. --Change these references to match your objects in the explorer
  8. local door = script.Parent.door
  9. local placeholder = script.Parent.placeholder
  10. local proxpro1 = script.Parent.button1.ProximityPrompt
  11. local proxpro2 = script.Parent.button2.ProximityPrompt
  12.  
  13. local closed = true
  14.  
  15. local duration = 4
  16.  
  17. local tweenservice = game:GetService("TweenService")
  18. local tweeninfo = TweenInfo.new(duration, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
  19.  
  20. local close = tweenservice:Create(door, tweeninfo, {CFrame = door.CFrame})
  21. local open = tweenservice:Create(door, tweeninfo, {CFrame = placeholder.CFrame})
  22.  
  23. proxpro1.Triggered:Connect(function()
  24.     proxpro1.Enabled = false
  25.     proxpro2.Enabled = false
  26.     if closed then
  27.         open:Play()
  28.         wait(duration)
  29.         closed = false
  30.     else
  31.         close:Play()
  32.         wait(duration)
  33.         closed = true
  34.     end
  35.     proxpro1.Enabled = true
  36.     proxpro2.Enabled = true
  37. end)
  38.  
  39. proxpro2.Triggered:Connect(function()
  40.     proxpro1.Enabled = false
  41.     proxpro2.Enabled = false
  42.     if closed then
  43.         open:Play()
  44.         wait(duration)
  45.         closed = false
  46.     else
  47.         close:Play()
  48.         wait(duration)
  49.         closed = true
  50.     end
  51.     proxpro1.Enabled = true
  52.     proxpro2.Enabled = true
  53. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement