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: Trying to make a loop in a for thing.

Previous Thread :: Next Thread 
rsdlegodude is not online. rsdlegodude
Top 100 Poster
Joined: 06 Jun 2008
Total Posts: 26089
31 Jan 2012 07:48 AM
I really have no idea how this is supposed to work.

local c = script.Parent:GetChildren()

while true do
for i=1,#c do
if (c[i].className == "Part") then
c[i].Transparency = 0
c[i].CanCollide = true
wait(2)
c[i].Reflectance = 0.4
wait(0.2)
c[i].Reflectance = 0
wait(0.8)
c[i].Reflectance = 0.4
wait(0.2)
c[i].Reflectance = 0
wait(0.8)
c[i].Reflectance = 0.4
wait(0.2)
c[i].Reflectance = 0
wait(0.8)
c[i].Transparency = 1
c[i].CanCollide = false
wait(5)
end
end
end

But anyway, I want all in the model to go through the loop simultaneously, which isn't happening.
Report Abuse
NeonBlox is not online. NeonBlox
Joined: 19 Oct 2008
Total Posts: 1462
31 Jan 2012 08:41 AM
for index,block in pairs(script.Parent:GetChildren()) do
if block.className == "Part" then
block.Transparency = 0
block.CanCollide = true
wait(2)
for i = 1,3 do
block.Reflectance = 0.4
wait(0.2)
block.Reflectance = 0
wait(0.8)
end
block.Transparency = 1
block.CanCollide = false
end
end

Wait, you want them to all go through at the same time? In that case.

Put this code in a script in workspace.

for index,block in pairs(script.Parent:GetChildren()) do
if block.className == "Part" then
code = game.Lighting.Changer:clone()
code.Parent = block
end
end

Put this code in a script called 'Changer' in Lighting.

block.Transparency = 0
block.CanCollide = true
wait(2)
for i = 1,3 do
block.Reflectance = 0.4
wait(0.2)
block.Reflectance = 0
wait(0.8)
end
block.Transparency = 1
block.CanCollide = false
Report Abuse
rsdlegodude is not online. rsdlegodude
Top 100 Poster
Joined: 06 Jun 2008
Total Posts: 26089
31 Jan 2012 10:02 AM
A bit of clarification:
-The blocks are in the same model as the script
-I want to use one script only
-The script needs to work for every block, no matter how many there are in the model
Report Abuse
NeonBlox is not online. NeonBlox
Joined: 19 Oct 2008
Total Posts: 1462
31 Jan 2012 10:18 AM
My method work's for every part in the model. Sorry, I made a error.

for index,block in pairs(script.Parent:GetChildren()) do
if block.className == "Part" then
code = game.Lighting.Changer:clone()
code.Parent = block
end
end

That script goes in a script in the model, but you'll need a script in lighting to clone into every brick. That's the only way I know of to get them all to run at once, unless you want to use coroutines.
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