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: for loop affecting 3 different values?

Previous Thread :: Next Thread 
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
01 May 2014 12:21 PM
Normally when I use a for loop on multi values at the same time, those values are the same. This time, however all 3 values are different.

I'm trying to create a for loop that takes these 3 values (2, 1, 2.5) in a mesh scale,
and reduce them to 0 in 10ths. For example the 1 is reduced by 0.1, 2 is reduced by 0.2, and 2.5 is reduced by 0.25.

for i = V, 0, V/10 do

something like that but I've never actually tried to change multiple values that are different with the same for loop before.
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
01 May 2014 12:31 PM
Hmmm

local startSize = mesh.Size --I forget what its called

for i = 10, 0, -1 do
mesh.Size = startSize-startSize/10
wait(.1)
end
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
01 May 2014 12:40 PM
I can't do that. That will end up resizing the mesh uniformly. The animation imposes a sort of squishing effect on the mesh that I just am not willing to give up.


I did try this:

local V =
script.Parent.ArcaneCrystal.Mesh.Scale.X and
script.Parent.ArcaneCrystal.Mesh.Scale.Y and
script.Parent.ArcaneCrystal.Mesh.Scale.Z
for i = V, 0, -(V/10) do
script.Parent.ArcaneCrystal.Mesh.Scale = Vector3.new(i, i, i)

wait() end


It works, but not correctly. For some reason it pumps the mesh up to a scale larger than its actually starting at and then reduces it slowly even though the wait its at nil.

I can attribute that to assigning V to 3 different values. It's a start but it needs to get fixed.


In case you're wondering the idea is that the mesh starts off at the assigned values in the original post and reduces the mesh size in quotients of 10, allowing for a squishing effect in the mesh. It's just an animation.





Actually... Now that I think about... I could just use a ModuleScript and type out the lengthy reductions manually... >_> *freakin face nuke*
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
01 May 2014 12:46 PM
I see what you mean now.

local size = Vector3.new(2, 1, 5) --What you want it to decrease it by
Or make a table for a more generic case

diffs = (.1, .2, .25)

for i = 10, 0, -1 do
mesh.Size = mesh.Size-Vector3.new(diffs[1], diffs[2], diffs[3])
end
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
01 May 2014 12:46 PM
*diffs = {.1, .2, .5}

Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
01 May 2014 12:59 PM
mesh.Scale btw
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
01 May 2014 01:02 PM
I don't understand that at all. where's the i come in? you put for i = 10, 0, -1 do but you arent showing the i in the function at all. are you saying that it can be used as a timer this way?
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
01 May 2014 01:07 PM
i is just a counter. It doesnt need to be used in the for loop, and the way I did it, i is essentially unnecessary.
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
01 May 2014 02:38 PM
I fiddled with it a bit and I think I understand for loops better now. Thank you.
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