Im making a game that has autogenerated rooms, and items that get moved to folders in the workspace when the game is loaded, however, I can t seem to get the if statements to work. I've tried many things and have not found a solution.

local function checkMoveDarkZone()
	for _, room in pairs(roomsFolder:GetChildren()) do
		for _, darkZonept in pairs(room:GetChildren()) do
			if darkZonept:IsA("BasePart") then
				if darkZonept.Name == "DarkZonePt" then
					darkZonept.Parent = zoneFolder:WaitForChild("DarkZone")
				end
			end
		end
	end
end

ive tried using "print" to check where the problem is, though it only works in code leading up to the if statements. also, there are no warnings in the output.

2 comments

0

Also, you could just do if darkZonept:IsA("BasePart") and darkZonept.Name == "DarkZonePt" later, it makes for better code!

0

By the way, is the script local, or server side?