Advertisement
Drvays

Door Script

Jun 3rd, 2024 (edited)
10,322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. --[[ Made by coolcapidog
  2. Channel ->> https://www.youtube.com/c/coolcapidog
  3. ]]
  4. local TweenService = game:GetService("TweenService")
  5.  
  6. local hinge = script.Parent.PrimaryPart
  7. local prompt = script.Parent.Base:FindFirstChildOfClass("ProximityPrompt")
  8. local Sound = nil
  9.  
  10. if script.Parent.Base:FindFirstChildOfClass("Sound") then
  11. Sound = script.Parent.Base:FindFirstChildOfClass("Sound")
  12. end
  13.  
  14. local goalOpen = {}
  15. goalOpen.CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(90), 0)
  16.  
  17. local goalClose = {}
  18. goalClose.CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)
  19.  
  20. local tweenInfo = TweenInfo.new(1)
  21. local tweenOpen = TweenService:Create(hinge, tweenInfo, goalOpen)
  22. local tweenClose = TweenService:Create(hinge, tweenInfo, goalClose)
  23.  
  24. prompt.Triggered:Connect(function()
  25. prompt.Enabled = false
  26. if prompt.ActionText == "Close" then
  27. tweenClose:Play()
  28. prompt.ActionText = "Open"
  29. else
  30. tweenOpen:Play()
  31. prompt.ActionText = "Close"
  32. end
  33. if Sound ~= nil then Sound:Play() end
  34. wait(1)
  35. prompt.Enabled = true
  36. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement