Advertisement
Arm4GeDon

simple door script (modified)

Sep 22nd, 2022
964
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. local TweenService = game:GetService("TweenService")
  2.  
  3. local door = script.Parent.Parent
  4. local hinge = script.Parent.Doorframe.Hinge
  5. local room = script.Parent.Parent.Parent
  6. local light = room.door_light.light
  7. local beep = room.door_light.light.beep
  8. local hitbox = door.Door.hitbox
  9. local openSound = door.Door.Base.Sound
  10.  
  11. local goalOpen = {}
  12. goalOpen.CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(90), 0)
  13.  
  14. local goalClose = {}
  15. goalClose.CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)
  16.  
  17. local tweenInfo = TweenInfo.new(1)
  18. local tweenOpen = TweenService:Create(hinge, tweenInfo, goalOpen)
  19. local tweenClose = TweenService:Create(hinge, tweenInfo, goalClose)
  20.  
  21. local opened = false
  22.  
  23. local function openDoor()
  24.     if opened == false then
  25.         tweenOpen:Play()
  26.         openSound:Play()
  27.         opened = true
  28.         wait(0.2)
  29.         light.Color = Color3.new(1, 0, 0.0156863)
  30.         beep:Play()
  31.     end
  32. end
  33.  
  34. hitbox.Touched:Connect(openDoor)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement