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: Help with pairs

Previous Thread :: Next Thread 
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 10:16 PM
for i,v in pairs(game.Workspace:GetChildren()) do
if v.Name=="x" then
game.Workspace.x.SB.Adornee = game.Workspace.x
game.Workspace.x.SB.Color = BrickColor.new ("Institutional white")
end
end



(SB is the name of the SelectionBox)

Ok so it only edits the properties of the first part named that has a child named SB. I want it to go through all of the parts named x with a child of SB and change the Adornee and BrickColor. Help?
Report Abuse
Ozzypig is not online. Ozzypig
Joined: 27 Mar 2008
Total Posts: 4906
09 Jun 2013 10:18 PM
In the for-block, "v" refers to the the current value it is iterating on. Use that instead of indexing game.Workspace.x again. Like this:

for i,v in pairs(game.Workspace:GetChildren()) do
if v.Name=="x" then
v.SB.Adornee = v
v.SB.Color = BrickColor.new ("Institutional white")
end
end
Report Abuse
expressmyself is not online. expressmyself
Joined: 19 Apr 2011
Total Posts: 1768
09 Jun 2013 10:19 PM
Why don't you make the SelectionBox's color white already just a question not a suggestion sorry.
Report Abuse
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 10:20 PM
22:19:52.922 - v is not a valid member of Workspace
Report Abuse
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 10:23 PM
Bump
Report Abuse
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 10:29 PM
It's is only changing the properties of one of the x's
Report Abuse
2unknown2 is not online. 2unknown2
Joined: 30 Oct 2011
Total Posts: 9351
09 Jun 2013 10:36 PM
for i,v in pairs(game.Workspace:GetChildren()) do
if v.ClassName == "Part" and v.Name == "x" then
game.Workspace.x.SB.Adornee = game.Workspace.x
game.Workspace.x.SB.BrickColor = BrickColor.new ("Institutional white")
end
end

Certified Scripter
Report Abuse
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 10:41 PM
Now explain to me what ClassName is? Is it the actual normal thing that Instance calls it? So the ClassName of my "x" would be Part?
Report Abuse
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 10:43 PM
Still didn't work. T_T
Report Abuse
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 10:47 PM
It's still only editing the Adornee of one of the SB's...
Report Abuse
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 10:49 PM
v == to one of the x.
and game.Workspace.x == the other x
Report Abuse
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 10:54 PM
Bump
Report Abuse
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 11:00 PM
Bump
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
09 Jun 2013 11:02 PM


this is all wrong
how are you going to set something to be it's own adornee
Report Abuse
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 11:04 PM
Ugh, here's the script i have right now....


for i,v in pairs(game.Workspace:GetChildren()) do
if v.ClassName == "Part" and v.Name == "x" then
v.SB.Adornee = game.Workspace.x
v.SB.Color = BrickColor.new ("Institutional white")
end
end
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
09 Jun 2013 11:06 PM
i still don't get it
your trying to find the part "x" then your trying to set "x"'s adornee to "x"
Report Abuse
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 11:09 PM
I've set the pairs to x so that i can select all of the part's that are named x and then select their children named SB and then change their adornee's to v

i meant to put v there but put x instead, and btw my friend fixed it on XF

here is the fixed script



for i,v in pairs(game.Workspace:GetChildren()) do
if v.ClassName == "Part" and v.Name == "x" then
v.SB.Adornee = v
v.SB.Color = BrickColor.new ("Institutional white")
end
end

Report Abuse
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 11:15 PM
for i,v in pairs(game.Workspace:GetChildren()) do
if v.ClassName == "Part" and v.Name == "x" then
if v.SB.Adornee ~= v then
v.SB.Adornee = v
v.SB.Color = BrickColor.new ("Institutional white")
v.Transparency = 1
else
while wait() do
for i = 1,10 do
v.CFrame = v.CFrame*CFrame.new(0,i,0)
wait()
v.CFrame = v.CFrame*CFrame.new(0,-i,0)
end
end
end
end
end



I added onto it to make it float up and down but it doesn't seem to float?
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