generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Table Data and anchored?? Please Help, a bit more advanced question

Previous Thread :: Next Thread 
xFortunato is not online. xFortunato
Joined: 25 Nov 2010
Total Posts: 865
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
xFortunato is not online. xFortunato
Joined: 25 Nov 2010
Total Posts: 865
23 Sep 2011 11:25 PM
Please anyone
Report Abuse
kingmod123 is not online. kingmod123
Joined: 16 May 2009
Total Posts: 699
23 Sep 2011 11:27 PM
You did c[1] instead of c[i]
Report Abuse
xFortunato is not online. xFortunato
Joined: 25 Nov 2010
Total Posts: 865
24 Sep 2011 12:33 AM
That doesn't affect the problem.
Report Abuse
natedogith1 is not online. natedogith1
Joined: 09 Aug 2008
Total Posts: 578
24 Sep 2011 12:36 AM
it should be false not False
Report Abuse
grimm343 is not online. 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
xFortunato is not online. xFortunato
Joined: 25 Nov 2010
Total Posts: 865
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
natedogith1 is not online. natedogith1
Joined: 09 Aug 2008
Total Posts: 578
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 is not online. 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
xFortunato is not online. xFortunato
Joined: 25 Nov 2010
Total Posts: 865
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 is not online. 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
xFortunato is not online. xFortunato
Joined: 25 Nov 2010
Total Posts: 865
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
xFortunato is not online. xFortunato
Joined: 25 Nov 2010
Total Posts: 865
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image