Local Script is not detecting parts at Workspace/Folder

I had this error recently. Before this, I did implanted some type of TweenService Script.
The script is here

local player = game.Players.LocalPlayer
local humrootpart = player.Character.HumanoidRootPart
local teleport1 = script.Parent.A
local place1 = game.Workspace.Elevator.Lobby
local db = false

teleport1.MouseButton1Click:Connect(function()
	if not db then
		db = true
		humrootpart.CFrame = place1.CFrame
		script.Parent.Parent.Visible = false
		wait(.5)
		db = false
	end
end)

I think you guys may guess what it does but if you don’t, it teleport the person to “Lobby” Part through GUI. But, even though this script was working perfectly fine, I started to get this error;

Lobby is not a valid member of Folder “Workspace.Elevator”

pls help before I go mad over this-

I don’t know much but instead of place1 = game.Workspace.Elevator.Lobby, maybe try place1 = game.Workspace.Elevator:WaitForChild('Lobby')

The game is trying to detect the game object before it’s even loaded. Use local place1 = game.Workspace:WaitForChild(“Elevator”):WaitForChild(“Lobby”)
Hope this helps.

2 Likes

Since the prior replies didn’t explain WaitForChild, it’s a method used to yield (temporarily suspend) the running thread until it finds an object with a matching name. Sometimes LocalScripts and Scripts begin execution before everything is loaded in, thus why WFC is essential in preventing this issue.

2 Likes

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