Advertisement
Arm4GeDon

ugly door script

Sep 23rd, 2022
1,444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.10 KB | None | 0 0
  1. local TweenService = game:GetService("TweenService")
  2.  
  3. local loadNumber = require(game.ServerScriptService.ModuleScript)
  4.  
  5. local door = script.Parent.Parent
  6. local doorPart = script.Parent.Base.Union
  7. local hinge = script.Parent.Doorframe.Hinge
  8. local room = script.Parent.Parent.Parent
  9. local light = room.door_light.light
  10. local beep = room.door_light.light.beep
  11. local hitbox = door.Door.hitbox
  12. local openSound = door.Door.Base.Sound
  13. local curDoor = workspace.curDoor
  14.  
  15. local needKey = door.Door.needKey
  16.  
  17. local goalOpen = {}
  18. goalOpen.CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(90), 0)
  19.  
  20. local goalClose = {}
  21. goalClose.CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)
  22.  
  23. local tweenInfo = TweenInfo.new(1)
  24. local tweenOpen = TweenService:Create(hinge, tweenInfo, goalOpen)
  25. local tweenClose = TweenService:Create(hinge, tweenInfo, goalClose)
  26.  
  27. local opened = false
  28.  
  29. local ogX = doorPart.Position.X
  30. local ogY = doorPart.Position.Y
  31. local ogZ = doorPart.Position.Z
  32.  
  33. local ogRotX = doorPart.Orientation.X
  34. local ogRotY = doorPart.Orientation.Y
  35. local ogRotZ = doorPart.Orientation.Z
  36.  
  37. local number = script.Parent.sign.singUI.number
  38.  
  39. local function moveDoor(degX, degY, degZ)
  40.     doorPart.Rotation = Vector3.new(ogRotX + degX, ogRotY + degY, ogRotZ + degZ)
  41.     doorPart.Position = Vector3.new(ogX + -2, ogY, ogZ + 2)
  42.     --doorPart.Transparency = 1
  43.     wait()
  44. end
  45.  
  46. local function openDoor()
  47.         loadNumber.loadDoorNumber(room.Name)
  48.         curDoor.Value += 1
  49.         number.Text = curDoor.Value
  50.         moveDoor(0, 270, 0)
  51.         openSound:Play()
  52.         opened = true
  53.         doorPart.Parent.CanCollide = false
  54.         wait(0.1)
  55.         light.Color = Color3.new(1, 0, 0.0156863)
  56.         beep:Play()
  57. end
  58.  
  59. local function onPartTouched(part)
  60.     if part.Parent.Humanoid then
  61.         if opened  == false and needKey ~= true then
  62.             print("Player " .. part.Parent.Name .. " Opened Door " .. curDoor.Value + 1)
  63.             openDoor()
  64.         end
  65.     end
  66. end
  67.  
  68. hitbox.Touched:Connect(onPartTouched)
  69.  
  70. --[[prompt.Triggered:Connect(function()
  71.     if prompt.ActionText == "Close" then
  72.         tweenClose:Play()
  73.         prompt.ActionText = "Open"
  74.     else
  75.         tweenOpen:Play()
  76.         prompt.ActionText = "Close"
  77.     end
  78. end)]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement