| efficiency | |
|
|
Author | Message |
---|
Guest Guest
| Subject: efficiency January 7th 2011, 3:45 pm | |
| basically i made a really long script and need to make more efficient..... instead of saying : - Code:
-
1.Transparency = 0 2.Transparency = 0 etc etc etc..... 16 times i would add another tag and say - Code:
-
model = script.Parent parts = model:FindFistChild.ClassName("Part")
parts.Transparency = 0 wud tht work? |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: efficiency January 8th 2011, 6:05 am | |
| - Code:
-
model = script.Parent parts = model:GetChildren() for _,part in ipairs(parts) if (part:IsA("BasePart")) then part.Transparency = 0 end end
Last edited by blueymaddog on January 9th 2011, 1:06 am; edited 1 time in total | |
|
| |
Guest Guest
| Subject: Re: efficiency January 8th 2011, 12:21 pm | |
| i got 1 other now...... - Code:
-
model = script.Parent part = model:GetChildern parts = part.ClassName = ("Part") parts.Transparency = 0
again wud tht work? |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: efficiency January 9th 2011, 1:07 am | |
| | |
|
| |
Supernapalm Expert Scripter
Posts : 393 Join date : 2011-01-17
| Subject: Re: efficiency January 24th 2011, 11:36 pm | |
| is this what your trying to do? - Code:
-
for part in ipairs(script.Parent:GetChildren()) do if part.ClassName == "Part" then part.Transparency = 0 end end the value of a key that is a table, since even parts on roblox are tables, is table:(%UniqueID%). you do know that right, blueymaddog?
Last edited by Supernapalm on January 25th 2011, 9:20 pm; edited 4 times in total | |
|
| |
myrco919 Intermediate Scripter
Posts : 190 Join date : 2011-01-21 Age : 26 Location : Holland
| Subject: Re: efficiency January 25th 2011, 5:44 am | |
| - Code:
-
local model = workspace.model:GetChildren()
for x=1, #model do if model[x].className == "Part" then model[x].Transparency = 0.5 end end | |
|
| |
Supernapalm Expert Scripter
Posts : 393 Join date : 2011-01-17
| Subject: Re: efficiency January 25th 2011, 11:54 pm | |
| | |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: efficiency January 26th 2011, 8:00 am | |
| | |
|
| |
Supernapalm Expert Scripter
Posts : 393 Join date : 2011-01-17
| Subject: Re: efficiency January 27th 2011, 3:09 am | |
| the value of a key that is a table is a unique id of how where the table is stored. you know that right? | |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: efficiency January 27th 2011, 8:07 am | |
| Yes. and the ID changes all the time. Try printing the same table twice. :P | |
|
| |
slayer9365 Expert Scripter
Posts : 233 Join date : 2010-07-31 Age : 29
| Subject: Re: efficiency January 27th 2011, 7:04 pm | |
| It will only change if you change it. | |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: efficiency January 27th 2011, 8:00 pm | |
| print _G twice. it prints different id's 0.o | |
|
| |
Supernapalm Expert Scripter
Posts : 393 Join date : 2011-01-17
| Subject: Re: efficiency January 27th 2011, 9:32 pm | |
| anyway, here's what you put - Code:
-
model = script.Parent parts = model:GetChildren() for _,part in ipairs(parts) if (part:IsA("BasePart")) then part.Transparency = 0 end end you contradicted yourself | |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: efficiency January 28th 2011, 12:14 am | |
| lolwhatiswrongwithmyscriptthatyourtryingtopointput? | |
|
| |
naknak Administrator
Posts : 878 Join date : 2010-07-30
| Subject: Re: efficiency January 28th 2011, 8:55 am | |
| Couldn't you just combine those two variables anyway? :D Felt like jumping in | |
|
| |
Supernapalm Expert Scripter
Posts : 393 Join date : 2011-01-17
| Subject: Re: efficiency January 28th 2011, 10:19 pm | |
| what i think is wrong is that you accessed part instead of _. | |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: efficiency January 29th 2011, 6:36 am | |
| mine is fine. for [name of the index it's iriterating through], key in ipairs(table) do | |
|
| |
Supernapalm Expert Scripter
Posts : 393 Join date : 2011-01-17
| Subject: Re: efficiency January 29th 2011, 2:35 pm | |
| i thought part was a key, not an index | |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: efficiency January 30th 2011, 6:48 am | |
| key is the value index is the name of where the key is stored in the table. | |
|
| |
Supernapalm Expert Scripter
Posts : 393 Join date : 2011-01-17
| Subject: Re: efficiency January 30th 2011, 5:45 pm | |
| i mean i thought part was an index, not a key. you are accessing the index. arent you supposed to access the key? | |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: efficiency February 11th 2011, 6:15 am | |
| sorry, I think I mislead u. when I said index I mean the index name and when I said key I meant the index. I think that makes more sense now. | |
|
| |
Sponsored content
| Subject: Re: efficiency | |
| |
|
| |
| efficiency | |
|