Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TweenService = game:GetService("TweenService")
- local loadNumber = require(game.ServerScriptService.ModuleScript)
- local door = script.Parent.Parent
- local doorPart = script.Parent.Base.Union
- local hinge = script.Parent.Doorframe.Hinge
- local room = script.Parent.Parent.Parent
- local light = room.door_light.light
- local beep = room.door_light.light.beep
- local hitbox = door.Door.hitbox
- local openSound = door.Door.Base.Sound
- local curDoor = workspace.curDoor
- local needKey = door.Door.needKey
- local goalOpen = {}
- goalOpen.CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(90), 0)
- local goalClose = {}
- goalClose.CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)
- local tweenInfo = TweenInfo.new(1)
- local tweenOpen = TweenService:Create(hinge, tweenInfo, goalOpen)
- local tweenClose = TweenService:Create(hinge, tweenInfo, goalClose)
- local opened = false
- local ogX = doorPart.Position.X
- local ogY = doorPart.Position.Y
- local ogZ = doorPart.Position.Z
- local ogRotX = doorPart.Orientation.X
- local ogRotY = doorPart.Orientation.Y
- local ogRotZ = doorPart.Orientation.Z
- local number = script.Parent.sign.singUI.number
- local function moveDoor(degX, degY, degZ)
- doorPart.Rotation = Vector3.new(ogRotX + degX, ogRotY + degY, ogRotZ + degZ)
- doorPart.Position = Vector3.new(ogX + -2, ogY, ogZ + 2)
- --doorPart.Transparency = 1
- wait()
- end
- local function openDoor()
- loadNumber.loadDoorNumber(room.Name)
- curDoor.Value += 1
- number.Text = curDoor.Value
- moveDoor(0, 270, 0)
- openSound:Play()
- opened = true
- doorPart.Parent.CanCollide = false
- wait(0.1)
- light.Color = Color3.new(1, 0, 0.0156863)
- beep:Play()
- end
- local function onPartTouched(part)
- if part.Parent.Humanoid then
- if opened == false and needKey ~= true then
- print("Player " .. part.Parent.Name .. " Opened Door " .. curDoor.Value + 1)
- openDoor()
- end
- end
- end
- hitbox.Touched:Connect(onPartTouched)
- --[[prompt.Triggered:Connect(function()
- if prompt.ActionText == "Close" then
- tweenClose:Play()
- prompt.ActionText = "Open"
- else
- tweenOpen:Play()
- prompt.ActionText = "Close"
- end
- end)]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement