Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

0
Theres no Errors or prints. RealHexYT 12 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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
Ad

Answer this question