Advertisement
XxxLloyd061302xxX

One-Door Script

May 18th, 2018
1,991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. --If you only have One door instead of Double door, Name the door part "Door1" and this is the script:
  2.  
  3.  
  4. local db= false
  5. local open = script.Parent.Open
  6.  
  7. script.Parent.Trigger.Touched:connect(function(p)
  8. if db == false then
  9. db = true
  10. if p.Parent:FindFirstChild("Card") ~= nil then
  11. if open.Value == false then
  12. local f = script.Parent.Door1.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
  13. for i = 0,1,0.1 do
  14. local cfm = script.Parent.Door1.PrimaryPart.CFrame:lerp(f,i)
  15. script.Parent.Door1:SetPrimaryPartCFrame(cfm)
  16. wait()
  17. end
  18. open.Value = true
  19. wait(3) -- how long does the doors open
  20. local f2 = script.Parent.Door1.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
  21. for i = 0,1,0.1 do
  22. local cfm = script.Parent.Door1.PrimaryPart.CFrame:lerp(f2,i)
  23. script.Parent.Door1:SetPrimaryPartCFrame(cfm)
  24. wait()
  25. end
  26. open.Value = false
  27. end
  28. else
  29. print("User has no card")
  30. end
  31. db=false
  32. end
  33. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement