Advertisement
XxxLloyd061302xxX

Two-Triggered Single Door Script

May 18th, 2018
1,697
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --If you only have One door instead of Double door, Name the door part "Door1" and this is the script:
  2.  
  3. local db= false
  4. local open = script.Parent.Open
  5.  
  6. script.Parent.Trigger.Touched:connect(function(p)
  7. if db == false then
  8. db = true
  9. if p.Parent:FindFirstChild("Card") ~= nil then
  10. if open.Value == false then
  11. local f1 = script.Parent.Door1.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
  12. for i = 0,1,0.1 do
  13. local cfm = script.Parent.Door1.PrimaryPart.CFrame:lerp(f1,i)
  14. script.Parent.Door1:SetPrimaryPartCFrame(cfm)
  15. wait()
  16. end
  17. open.Value = true
  18. wait(3) -- how long does the doors open
  19. local f2 = script.Parent.Door1.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
  20. for i = 0,1,0.1 do
  21. local cfm = script.Parent.Door1.PrimaryPart.CFrame:lerp(f2,i)
  22. script.Parent.Door1:SetPrimaryPartCFrame(cfm)
  23. wait()
  24. end
  25. open.Value = false
  26. end
  27. else
  28. print("User has no card")
  29. end
  30. db=false
  31. end
  32. end)
  33.  
  34. script.Parent.Trigger2.Touched:connect(function(p)
  35. if db == false then
  36. db = true
  37. if p.Parent:FindFirstChild("Card") ~= nil then
  38. if open.Value == false then
  39. local f1 = script.Parent.Door1.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
  40. for i = 0,1,0.1 do
  41. local cfm = script.Parent.Door1.PrimaryPart.CFrame:lerp(f1,i)
  42. script.Parent.Door1:SetPrimaryPartCFrame(cfm)
  43. wait()
  44. end
  45. open.Value = true
  46. wait(3) -- how long does the doors open
  47. local f2 = script.Parent.Door1.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
  48. for i = 0,1,0.1 do
  49. local cfm = script.Parent.Door1.PrimaryPart.CFrame:lerp(f2,i)
  50. script.Parent.Door1:SetPrimaryPartCFrame(cfm)
  51. wait()
  52. end
  53. open.Value = false
  54. end
  55. else
  56. print("User has no card")
  57. end
  58. db=false
  59. end
  60. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement