XxxLloyd061302xxX

Door Script

May 18th, 2018
1,720
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. local db= false
  2. local open = script.Parent.Open
  3.  
  4. script.Parent.Trigger.Touched:connect(function(p)
  5. if db == false then
  6. db = true
  7. if p.Parent:FindFirstChild("Card") ~= nil then
  8. if open.Value == false then
  9. local f = script.Parent.Door1.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
  10. local f2 = script.Parent.Door2.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
  11. for i = 0,1,0.1 do
  12. local cfm = script.Parent.Door1.PrimaryPart.CFrame:lerp(f,i)
  13. local cfm2 = script.Parent.Door2.PrimaryPart.CFrame:lerp(f2,i)
  14. script.Parent.Door1:SetPrimaryPartCFrame(cfm)
  15. script.Parent.Door2:SetPrimaryPartCFrame(cfm2)
  16. wait()
  17. end
  18. open.Value = true
  19. wait(3) -- how long does the doors open
  20. local f3 = script.Parent.Door1.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
  21. local f4 = script.Parent.Door2.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
  22. for i = 0,1,0.1 do
  23. local cfm = script.Parent.Door1.PrimaryPart.CFrame:lerp(f3,i)
  24. local cfm2 = script.Parent.Door2.PrimaryPart.CFrame:lerp(f4,i)
  25. script.Parent.Door1:SetPrimaryPartCFrame(cfm)
  26. script.Parent.Door2:SetPrimaryPartCFrame(cfm2)
  27. wait()
  28. end
  29. open.Value = false
  30. end
  31. else
  32. print("User has no card")
  33. end
  34. db=false
  35. end
  36. end)
  37.  
  38. script.Parent.Trigger2.Touched:connect(function(p)
  39. if db == false then
  40. db = true
  41. if p.Parent:FindFirstChild("Card") ~= nil then
  42. if open.Value == false then
  43. local f = script.Parent.Door1.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
  44. local f2 = script.Parent.Door2.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
  45. for i = 0,1,0.1 do
  46. local cfm = script.Parent.Door1.PrimaryPart.CFrame:lerp(f,i)
  47. local cfm2 = script.Parent.Door2.PrimaryPart.CFrame:lerp(f2,i)
  48. script.Parent.Door1:SetPrimaryPartCFrame(cfm)
  49. script.Parent.Door2:SetPrimaryPartCFrame(cfm2)
  50. wait()
  51. end
  52. open.Value = true
  53. wait(3) -- how long does the doors open
  54. local f3 = script.Parent.Door1.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
  55. local f4 = script.Parent.Door2.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
  56. for i = 0,1,0.1 do
  57. local cfm = script.Parent.Door1.PrimaryPart.CFrame:lerp(f3,i)
  58. local cfm2 = script.Parent.Door2.PrimaryPart.CFrame:lerp(f4,i)
  59. script.Parent.Door1:SetPrimaryPartCFrame(cfm)
  60. script.Parent.Door2:SetPrimaryPartCFrame(cfm2)
  61. wait()
  62. end
  63. open.Value = false
  64. end
  65. else
  66. print("User has no card")
  67. end
  68. db=false
  69. end
  70. end)
Add Comment
Please, Sign In to add comment