|
How do I check to see if an object is in a certain model?
if Object not == nil then
Is that how? |
|
|
if Object ~= nil then
+-Fishy |
|
|
Won't that just make it so that it checks if its not there? |
|
aboy5643Join Date: 2010-10-08 Post Count: 5458 |
Use ::FindFirstChild(objName)
Otherwise you'll get an error about accessing a nil value. |
|
stravantForum ModeratorJoin Date: 2007-10-22 Post Count: 2893 |
Well, a typical way of writing it would look something like this:
if model:FindFirstChild("Name of the thing") then
... |
|
|
if Object ~=nil then --This says that "If Object does not equal nothing then...". Literally. In other words, it's saying "If Object equals something then..."
+-Fishy |
|
iFordMCJoin Date: 2011-08-26 Post Count: 1491 |
While true do
for i, v in impairs (game.workspace:GetChildren())
If game.Workspace[v]:IsA("Model") then
If game.Workspace[v].Bricky ~= false then
-- Code here
End
End
End
Else
Print("It is false!")
End |
|
NewFissyJoin Date: 2011-01-03 Post Count: 1303 |
You could also compare the object's parent to the model.
Model = workspace.Model
Object = script.Parent
if Object.Parent == Model then
print("In Model")
end |
|
iFordMCJoin Date: 2011-08-26 Post Count: 1491 |
I think that was wrong, how embarrassing. Especially science strap ant may see... |
|
iFordMCJoin Date: 2011-08-26 Post Count: 1491 |
Auto correct. |
|
|
Thanks Stravant. and the rest of you for pitching in. |
|