Can't find ___ in workspace error

Hello everyone!

So I want to make a Bollard System inside of Roblox Studio and I get the error

Enable to find:  Main
Enable to find:  End

The problem is that the Main & End are in the game and are not removed from the game.

This is the script :

local bollardsLowered = false



Settings.Data.Bollards1.ModelData.ProximityPrompt.Triggered:Connect(function()
	if not bollardsLowered then
		local tweens = {} 
		local flashes = {}
		local Folder = Settings.Data.Bollards1.ModelData.BollardFolder:GetDescendants()
		for _, bollard in pairs(Folder) do
			if bollard:IsA("Model") then
				local Main = bollard:FindFirstChild("Main")
				local End = bollard:FindFirstChild("End")
				if Main and End then
					local OriginalLedsCFr = Main:FindFirstChild("Leds").CFrame
					local OriginalCFrame = End.Union.CFrame
					local tween1 = TweenService:Create(Main.Leds, info, {CFrame = End.Leds.CFrame})
					local tween2 = TweenService:Create(Main.Union, info, {CFrame = End.Union.CFrame})
					table.insert(tweens, tween1)
					table.insert(tweens, tween2)
					table.insert(flashes, function() Flash(bollard, false, OriginalLedsCFr, End.Union.CFrame) end)  -- Ajouter la fonction Flash
				else
					warn("Enable to find: ", bollard.Name)
				end
			end
		end
		for _, tween in ipairs(tweens) do
			tween:Play()
		end
		for _, flashFunc in ipairs(flashes) do
			flashFunc()
		end
		bollardsLowered = true
		table.clear(tweens)
	else
		local tweens = {} 
		local Folder = Settings.Data.Bollards1.ModelData.BollardFolder:GetDescendants()
		for _, bollard in pairs(Folder) do
			if bollard:IsA("Model") then
				local Main = bollard:FindFirstChild("Main")
				local End = bollard:FindFirstChild("End")
				if Main and End then
					local OriginalLedsCFr = Main:FindFirstChild("Leds").CFrame
					local OriginalCFrame = End.Union.CFrame
					local tween1 = TweenService:Create(Main.Leds, info, {CFrame = OriginalLedsCFr})
					local tween2 = TweenService:Create(Main.Union, info, {CFrame = OriginalCFrame})
					table.insert(tweens, tween1)
					table.insert(tweens, tween2)
					Flash(bollard, true, OriginalLedsCFr, End.Union.CFrame)  
				end
			end
		end
		for _, tween in ipairs(tweens) do
			tween:Play()
		end
		bollardsLowered = false
	end
end)

Workspace Screenshot :
image

Video :
Untitled Game - Roblox Studio 2024-04-01 15-26-13.mp4 - Google Drive

All reply helps!

Try replacing :FindFirstChild() with :WaitForChild() when your defining the Main and End variables. I think the two models just aren’t loading in time.

1 Like

Thank you for helping but this doesn’t work. When I fire the proximity prompt, nothing happens.

Make sure the path to the folder is correct

Thank you for the help but it’s not a problem with the path!

There are only 3 possibilities I can think of:

  1. The End and Main models don’t exist in-game. Do they get removed? Are they unanchored and fall out of the map? Make sure you check that.
  2. You’re referring to the wrong folder. (but you said it isn’t the case)
  3. Are there multiple models named “bollard” inside of the folder?

Does this mean the ‘not found’ error went away?

I think you need to add print statements to find out what its actually doing.

Watch the video

I think I found the issue:

will get all descendants in the Bollards folder, this includes Bollard1, Bollard, AND the Main/End models. Since your script only checks whether what you’re looping over is a Model, it also tries to look for Main and End models inside the Main and End models themselves. To fix this, you should only looping through children and not descendants, and you should be looking for Main and End in the Bollard model rather than all descendants/the Bollard1 folder.

2 Likes

Thanks man! This really helps!

1 Like

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