-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNicolasDoor.lua
102 lines (57 loc) · 2.03 KB
/
NicolasDoor.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
-- Settings --
local waittime = 5 -- How long doors will be open (you must set speed and you must set wait time in card reader
local doorspeed = 1 -- Door Speed
--------------------------------------------------------------------------------------------
-- Ignore this down here its the door's system --
-- Dont touch!!! --
--Locations--
local l = script.Parent.MotorL
local r = script.Parent.MotorR
local value = script.Parent.Open
local lock = script.Parent.Lock
-- Door Speed --
script.Parent.MotorL.Hinge.AngularSpeed = doorspeed
script.Parent.MotorR.Hinge.AngularSpeed = doorspeed
---------------------------------------------------
-- Door Lock --
script.Parent.Open.Changed:Connect(function(a)
if a == false then
lock.Lock1.Lig.Color = Color3.fromHSV(0.347028, 1, 0.811765)
lock.Lock2.Lig.Color = Color3.fromHSV(0.347028, 1, 0.811765)
wait(waittime)
lock.Lock1.Lock.Locking.Enabled = true
lock.Lock2.Lock.Locking.Enabled = true
lock.Lock1.Lig.Color = Color3.fromHSV(0, 0, 1)
lock.Lock2.Lig.Color = Color3.fromHSV(0, 0, 1)
elseif script.Parent.Open.Value == true then
lock.Lock1.Lock.Locking.Enabled = false
lock.Lock2.Lock.Locking.Enabled = false
lock.Lock1.Lig.Color = Color3.fromHSV(0, 1, 0.796078)
lock.Lock2.Lig.Color = Color3.fromHSV(0, 1, 0.839216)
end
end)
------------------------------------------------------------------------------
-- Door Movement --
value.Changed:Connect(function(o)
if o == false then --Door close
r.Hinge.TargetAngle = 0
l.Hinge.TargetAngle = 0
wait(5)
script.Parent.Lock.locked.Value = false
-------------------------
elseif value.Value == true then --Door open
r.Hinge.TargetAngle = 90
l.Hinge.TargetAngle = -90
script.Parent.Lock.locked.Value = true
-------------------------
end
end)
------------------------------------------------
-- Sensor --
function onTouch(hit)
script.Parent.Open.Value = true
wait(3)
script.Parent.Open.Value = false
end
script.Parent.Sensor.Touched:connect(onTouch)
---------------------------------------------