Help me with infinity yield possible bug

Here’s the snippet from my code:

task.wait(5)

local ScriptingsFolder = workspace:WaitForChild("Scriptings")
local DoorsFolder = ScriptingsFolder:WaitForChild("Doors")

for _, Door in ipairs(DoorsFolder:GetChildren()) do
	if Door and Door:IsA("Model") then
		local DoorKnob = Door:FindFirstChild("Knob")
		if DoorKnob then
			local DoorAttachment = DoorKnob:FindFirstChild("Attachment")
			if DoorAttachment then
				local DoorProximity = DoorAttachment:FindFirstChild("ProximityPrompt")
				if DoorProximity then
					DoorProximity.Triggered:Connect(function()
						DoorProximity.Enabled = false
						task.delay(0.75, function()
							DoorProximity.ActionText = "Leave"
							DoorProximity.Enabled = true
						end)
						Controls:Disable()
						Humanoid.AutoRotate = false
						QueueEvent:FireServer(Door)
					end)

					ControlEvent.OnClientEvent:Connect(function(Action, Angle)
						if Action == "Unlock" then
							DoorProximity.Enabled = false
							task.delay(0.75, function()
								DoorProximity.Enabled = true
								DoorProximity.ActionText = "Queue"
							end)
							Controls:Enable()
							Humanoid.AutoRotate = true
						elseif Action == "Lock" and Angle then
							local Position = HumanoidRootPart.Position
							HumanoidRootPart.CFrame = CFrame.new(Position) * CFrame.Angles(0, math.rad(Angle), 0)
						end
					end)
				else
					warn("ProximityPrompt not found in DoorAttachment for door: " .. Door.Name)
				end
			else
				warn("Attachment not found in Knob for door: " .. Door.Name)
			end
		else
			warn("Knob not found directly under door: " .. Door.Name)
		end
	end
end

I keep getting the warning: Attachment not found in Knob for door: Door1.

I’m 100% sure that the door structure is correct. I’ve tried everything, including adding a 5-second delay before the script runs, but the issue persists.

Below is an image of the door structure:
image

And also it’s another local script and not the DoorsHandler script. Any solution?

2 Likes

Can you add more debugging by printing out door:GetDescendants() and looking through the table? Also what is the reason for an attatchment, the proximityprompt can be inside the knob itself. One more thing, is the script server sided or client sided? I see there is a DoorsHandler script but you are getting the folder from workspace.

1 Like

Apologies for the misunderstanding. I edited the message above while you were typing and added the following:

Regarding debugging, could you clarify what you mean by door:GetDescendants()? I’ve been using print statements.

1 Like

Sorry for the misunderstandment, can you add print(Door:GetDescendants()) afterif Door?

1 Like


You can see that the attachment exists, yet the warning still appears, and the function for interacting with the proximity prompt isn’t working.

Hmmm could you do that for DoorKnob instead?

image
That’s wierd?

From the previous image I can see that there are 2 knobs, this is likely the cause of the issue. If that is not the issue I would suggest changing the doormodels streaming to Persistent so it doesn’t get streamed out (if necessary)

2 Likes

H-Hold on… HOW I DIDN’T NOTICE THAT…

Thanks for your help in figuring this out. The issue was that there were two elements with the same knob name in the door, and the script was checking the Motor6D instead of the MeshPart.

1 Like

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