Advertisement
XxxLloyd061302xxX

Door Script

May 18th, 2018
5,060
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement