I'm trying to get a the value of a intvalue from a part from 2 model so what i tried i
local E = game.Workspace.House --There 2 Model Called "House" but i don't want to rename them local F = E:FindFirstChild("House Pass") if F then print("Openned") else print("Acces Denied")
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) -- This would insert the model into the table previously created. 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) -- This would insert the model into the table previously created. end end for i,v in pairs(Table) do if v:IsA("Model") then -- Making sure that the object being looped through is a model. if v:FindFirstChild("House Pass") and v:FindFirstChild("House Pass"):IsA("IntValue") then -- searching for the house pass integer. print("Opened "..v.Name) else print("Access denied from "..v.Name) end end end
Hopefully this helped.