mirror of
https://github.com/codeninjasuk/roblox-world-24.git
synced 2024-11-25 17:08:00 -05:00
Create sliding_door.cs
This commit is contained in:
parent
c6bc88ffb9
commit
019d713cf9
1 changed files with 28 additions and 0 deletions
28
sliding_door.cs
Normal file
28
sliding_door.cs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
local door = script.Parent
|
||||||
|
local location = door.Parent.Placeholder
|
||||||
|
local state = "closed"
|
||||||
|
local ts = game: GetService("TweenService")
|
||||||
|
local info = TweenInfo.new()
|
||||||
|
local close = ts: Create(door, info, {
|
||||||
|
CFrame = door.CFrame
|
||||||
|
})
|
||||||
|
local open = ts: Create(door, info, {
|
||||||
|
CFrame = location.CFrame
|
||||||
|
})
|
||||||
|
for i,
|
||||||
|
part in door.Parent: GetDescendants() do
|
||||||
|
if part: IsA("ProximityPrompt") then part.Triggered: Connect(function() door.trigger: Play() if state == "open"
|
||||||
|
then
|
||||||
|
close: Play()
|
||||||
|
door.close: Play()
|
||||||
|
else open: Play() door.open: Play() end part.Enabled = false end) end end close.Completed: Connect(function() for i, part in door.Parent: GetDescendants() do
|
||||||
|
if part: IsA("ProximityPrompt") then part.Enabled = true state = "closed"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
open.Completed: Connect(function()
|
||||||
|
for i, part in door.Parent: GetDescendants() do
|
||||||
|
if part: IsA("ProximityPrompt") then part.Enabled = true state = "open"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
Loading…
Reference in a new issue