There are a few problems with your script. I will address them as we move through this post.
If you don't want to rename one of the models called "House", you can simply use a table. You would use a table like so:
local Table = {}
Now, we need to address the houses. To do this we would use a loop. This loop will run through the workspace to search for any object named "House":
local Table = {}
for i,v in pairs(workspace:GetChildren()) do
if v.Name == "House" then
table.insert(Table, v)
end
end
Now that we have each house in the table, we would need to create another loop to search everything in the table for a "House Pass" integer value. You would do so like this:
local Table = {}
for i,v in pairs(workspace:GetChildren()) do
if v.Name == "House" then
table.insert(Table, v)
end
end
for i,v in pairs(Table) do
if v:IsA("Model") then
if v:FindFirstChild("House Pass") and v:FindFirstChild("House Pass"):IsA("IntValue") then
print("Opened "..v.Name)
else
print("Access denied from "..v.Name)
end
end
end
Hopefully this helped.
1 comment
is this like a key card to open a door