krLuCiEzkr

Sliding Door Script

Dec 10th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. local TweenService = game:GetService("TweenService")
  2. local door1 = script.Parent:WaitForChild("Door1")
  3. local door2 = script.Parent:WaitForChild("Door2")
  4. local tweeningInformation = TweenInfo.new(
  5. 0.5,
  6. Enum.EasingStyle.Linear,
  7. Enum.EasingDirection.Out,
  8. 0,
  9. false,
  10. 0
  11. )
  12. local door1Open = {CFrame = CFrame.new(-4.23, 3.99, -8.56)}
  13. local door2Open = {CFrame = CFrame.new(-26.57, 3.99, -8.56)}
  14. local door1Close = {CFrame = CFrame.new(-11.57, 3.99, -8.56)}
  15. local door2Close = {CFrame = CFrame.new(-18.91, 3.99, -8.56)}
  16. local tween1open = TweenService:Create(door1,tweeningInformation,door1Open)
  17. local tween1close = TweenService:Create(door1,tweeningInformation,door1Close)
  18. local tween2open = TweenService:Create(door2,tweeningInformation,door2Open)
  19. local tween2close = TweenService:Create(door2,tweeningInformation,door2Close)
  20.  
  21. script.Parent.Detector1.Touched:Connect(function(hit)
  22. tween1open:Play()
  23. tween2open:Play()
  24. wait(2)
  25. tween1close:Play()
  26. tween2close:Play()
  27. end)
  28. script.Parent.Detector2.Touched:Connect(function(hit)
  29. tween1open:Play()
  30. tween2open:Play()
  31. wait(2)
  32. tween1close:Play()
  33. tween2close:Play()
  34. end)
Add Comment
Please, Sign In to add comment