From 019d713cf952b185b24cb54c377a74119fa17b11 Mon Sep 17 00:00:00 2001 From: Elvis Tony Date: Wed, 29 May 2024 10:23:37 +0100 Subject: [PATCH] Create sliding_door.cs --- sliding_door.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 sliding_door.cs diff --git a/sliding_door.cs b/sliding_door.cs new file mode 100644 index 0000000..b475919 --- /dev/null +++ b/sliding_door.cs @@ -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)