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: Model Script

Previous Thread :: Next Thread 
robloxcreater5000 is not online. robloxcreater5000
Joined: 10 Dec 2009
Total Posts: 74
30 Dec 2011 06:07 PM
I know how to script a brick to do something, like change the transparency every 0.5 seconds. But I would like that to happen to 10 more bricks in a model. So I wouldn't have to enable all scripts at once. I have created a script where you put it in the model with the bricks. For example:

Model
Script
Brick
Brick
Brick
Brick
Brick
Brick
Brick
Brick
Brick
Brick

So I did this:

test = script.Parent.Brick

while true do
test.Transparency = 0.9
wait(0.5)
test.Transparency = 0.1
wait(0.5)
end

I would of expected that when I classified Brick and there is 10 items named Brick. They would all be affected. But no, only 1 was changing transparency. Then I figured out that you have to change each brick's name to be different from each other. For example:

Model
Script
Brick1
Brick2
Brick3
Brick4
Brick5
Brick6
Brick7
Brick8
Brick9
Brick10

And the script would be this:

test1 = script.Parent.Brick1
test2 = script.Parent.Brick2
test3 = script.Parent.Brick3
test4...
test5...
test6...
test7...
test8...
test9...
test10...

while true do
test1.Transparency = 0.9
test2.Transparency = 0.9
test3.Transparency = 0.9
...
wait(0.5)
test1.Transparency = 0.1
test2.Transparency = 0.1
test3.Transparency = 0.1
...
wait(0.5)
end


But I don't want to change each of brick's names and do the same thing in the scripting. Is there a script where all bricks in the model will be affected to all of the same named bricks?

Please Respond.
Appreciate the support.
Report Abuse
nickmaster24 is not online. nickmaster24
Joined: 04 Oct 2008
Total Posts: 8906
30 Dec 2011 06:10 PM


If you have a Model filled with just bricks then:



Model = game.Workspace.Model:getChildren()

for i = 1, #Model do
Model[i].Name = "pie"
end


All of the bricks' names change to pie.

~Read Between the Squiggles~
Report Abuse
Ravenshield is not online. Ravenshield
Joined: 21 Nov 2007
Total Posts: 4143
30 Dec 2011 06:14 PM
You could also do something like this:

for _,v inpairs(script.Parent:GetChildren()) do
if v:IsA("Part") then
v.Transparency = 0.1
end

This snippet makes all parts of the model (script.Parent) into Transparency=0.1
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
30 Dec 2011 06:52 PM
@RavenShield <- You win.
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