Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Scan function not working correctly, what am I doing wrong?

Hey guys, so this scanner is not working correctly and I have no idea what im doing wrong!

local scanlocation = workspace:GetChildren()

knownmodels = {"PalmTree","AppleTree","OrangeTree"}

 for i,v in pairs(knownmodels) do
	if scanlocation.Name == v then 
		print("Found Known Model")
	end
end

I have the model called PalmTree in the workspace, yet it's not printing

1 comment

0

Theres no Errors or prints.

1 answer

✓ Accepted answer

workspace:GetChildren()'s Name is nil. A better option would be to iterate workspace's children and scan that way.

local knownmodels = {"PalmTree","AppleTree","OrangeTree"}

for _,KnownModel in pairs(knownmodels) do
	for _,WorkspaceChild in pairs(workspace:GetChildren()) do
		if KnownModel == WorkspaceChild.Name then
			print("Found Known Model")
		end
	end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.