[SOLVED] Problem with CollectionService for Doors

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

Updation*

local CollectionService = game:GetService("CollectionService")
local TweenService = game:GetService("TweenService")

local Doors = workspace:WaitForChild("Handler (W)").Map.KillArea.Doors.Door
local Tagged = CollectionService:GetTagged("Doors")

for i, Door in pairs(Tagged) do
local DoorOpen = Doors.DoorOpen
local DoorClose = Doors.DoorClose
local OpenSound = Doors.Door.DoorOpen
local CloseSound = Doors.Door.DoorClose
local ProximityPrompt = Doors.Door.ProximityPrompt
	
	ProximityPrompt.Triggered:Connect(function()
		if 	ProximityPrompt.ActionText == "Close" then
			ProximityPrompt.ActionText = "Open"
			CloseSound:Play()
			Tagged.CanCollide = true
			TweenService:Create(Tagged, TweenInfo.new(.35),{CFrame = DoorClose.CFrame}):Play()
		else
			ProximityPrompt.ActionText = "Close"
			OpenSound:Play()
			TweenService:Create(Tagged, TweenInfo.new(.35),{CFrame = DoorOpen.CFrame}):Play()
		end
	end)
end
1 Like

Still confused about what’s the problem.

Ohh I forgot to Update this post, I asked one of my mates to help and he ended up fixing the issue.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.