how can I compare all Doors to CollectionService
.
local CollectionService = game:GetService("CollectionService")
local TweenService = game:GetService("TweenService")
for i, Doors in pairs(CollectionService:GetTagged("Doors")) do
local Door = workspace:WaitForChild("Handler (W)").Map.KillArea.Doors.Door
local Frame = Door:WaitForChild("Door")
local OpenSound = Frame:WaitForChild("DoorOpen")
local CloseSound = Frame:WaitForChild("DoorClose")
local ProximityPrompt = Frame:WaitForChild("ProximityPrompt")
local FrameClose = Door:WaitForChild("DoorClose")
local FrameOpen = Door:WaitForChild("DoorOpen")
ProximityPrompt.Triggered:Connect(function()
if ProximityPrompt.ActionText == "Close" then
ProximityPrompt.ActionText = "Open"
OpenSound:Play()
Frame.CanCollide = true
TweenService:Create(Frame, TweenInfo.new(.35),{CFrame = FrameClose.CFrame}):Play()
else
ProximityPrompt.ActionText = "Close"
CloseSound:Play()
TweenService:Create(Frame, TweenInfo.new(.35),{CFrame = FrameOpen.CFrame}):Play()
end
end)
end