|
| 23 Sep 2011 10:31 PM |
function unanch(itempick, floornum)
local a = game.Workspace.OfficeBuilding.a:findFirstChild(floornum)
if a ~= nil then print (a) local c = a:GetChildren() for i=1, #c do if c[1].Name == itempick then newvar = c[1].Name modelt = a:findFirstChild(newvar) if modelt ~= nil then modelt.Anchored = False end end end end end
This script is meant to find all children of the model "a" and then set each anchored position to False. The script works fine if I replace { modelt.Anchored = False } with { modelt.Parent = game.Workspace }
Is there some limitation on what these table data can do? |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 Sep 2011 11:27 PM |
| You did c[1] instead of c[i] |
|
|
| Report Abuse |
|
|
|
| 24 Sep 2011 12:33 AM |
| That doesn't affect the problem. |
|
|
| Report Abuse |
|
|
|
| 24 Sep 2011 12:36 AM |
| it should be false not False |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 24 Sep 2011 12:37 AM |
| Yes. Nate is right. 'False' is not seen the same as 'false'. |
|
|
| Report Abuse |
|
|
|
| 24 Sep 2011 12:53 AM |
weird I tried putting part.Anchored = False in the command line to check before making the thread and it worked Anyway, part.Anchored = False and part.Anchored = false both make the boolean value false, but you are right the correct nomenclature is 'false' Changing the script to include 'false' instead of False did not solve the problem |
|
|
| Report Abuse |
|
|
|
| 24 Sep 2011 12:57 AM |
king is right that "c[1]" should be "c[i]" you should use print to see what section is being skipped |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 24 Sep 2011 12:58 AM |
I don't remember there being an "Anchored" property to a model, assuming modelt is a model.
Also, you are running this function through something that defines 'itempick' and 'floornum', right? |
|
|
| Report Abuse |
|
|
|
| 24 Sep 2011 09:31 AM |
The function works normally if modlt.Parent = game.Workspace and modelt is a part, not a modelt |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 24 Sep 2011 09:33 AM |
May as well try some different things, right?
function unanch(itempick, floornum)
local a = game.Workspace.OfficeBuilding.a:FindFirstChild(floornum)
if a ~= nil then print (a) local c = a:GetChildren() for i=1, #c do if c[i].Name == itempick then newvar = c[i].Name modelt = a:findFirstChild(newvar) if modelt ~= nil then modelt.Anchored = false end end end end end
|
|
|
| Report Abuse |
|
|
|
| 24 Sep 2011 09:52 AM |
I tried that. And just incase I changed newvar and itempick to the actual "strings" that I wanted to be found. Like I said it all works when modelt.Parent = game.Workspace, the parts under Model "a" move to the Workspace as their parents, but Anchored doesn't do anything.
I think it has something to do with limitations on tables. |
|
|
| Report Abuse |
|
|
|
| 24 Sep 2011 10:42 AM |
Oh wow, major facepalm. The problem was the findFirstChild(newvar) It was finding the first child in "a" with the name "newvar" The only problem is that all the children of "a" are named "OuterWall," so it was finding the same first one and setting it to false every time
I changed it to
c[i].Anchored = false
and it works now
Thanks to everyone that tried to help
|
|
|
| Report Abuse |
|
|