A Roblox Community

A community of Robloxians who want to learn to script and build on Roblox Studio.
 
HomeFAQRegisterLog in
If you're a experienced coder make some tutorials! It would really help the site grow.
Make sure you read the rules(Which can be found by clicking here)
If you're a beginner at coding, try some tutorials.
We have many Moderators/Admins watching this site. Contact them with Questions.
Let us know what your favorite sport is. By clicking here to vote (Click here)
This site is becoming inactive. Lets make it active.
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Top posters
blueymaddog
 
naknak
 
Supernapalm
 
m27frogy
 
slayer9365
 
myrco919
 
branefreez
 
ninga95
 
CloneTrooper787
 
raboy117
 
Top posting users this month
Latest topics
» Send me an Email
January 8th 2016, 10:14 am by naknak

» [v1.6.0.0] Lua Script Obfuscator [No Bytecode]
July 6th 2015, 7:38 pm by m27frogy

» New Site Possibly
July 6th 2015, 4:16 pm by m27frogy

» Ambassador!
April 15th 2015, 11:40 pm by naknak

» Boop - Tag
April 13th 2015, 9:46 pm by naknak

» Vip Class Script
April 13th 2015, 4:54 pm by naknak

» Who's active?!
April 13th 2015, 4:52 pm by naknak

» Where to go from here.
April 13th 2015, 4:51 pm by naknak

» Genesis Point
July 17th 2014, 7:04 pm by branefreez

» Reward System
July 17th 2014, 5:41 am by m27frogy

» Script Request
July 10th 2014, 11:43 am by naknak

» local scripts?
July 10th 2014, 11:39 am by naknak

» Project: Reconstruction [Died]
July 10th 2014, 11:36 am by naknak

» Hi. I am new here
April 26th 2014, 4:01 pm by altshiftkey

» What's your favorite sport?
January 1st 2014, 2:13 pm by m27frogy

» FlashLight Script
January 1st 2014, 2:11 pm by m27frogy

» Gun Making! [READ DESC]
January 1st 2014, 2:10 pm by m27frogy

» Hi, I am new here!
November 26th 2013, 3:33 pm by Keanu73

» Improve Coding
October 26th 2013, 1:12 pm by pook03

» Simple Button
September 1st 2013, 6:19 pm by branefreez


Share | 
 

 efficiency

View previous topic View next topic Go down 
AuthorMessage
Guest
Guest



PostSubject: 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?
Back to top Go down
blueymaddog
Administrator
Administrator
avatar

Posts : 1081
Join date : 2010-12-09
Age : 19

PostSubject: 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
Back to top Go down
Guest
Guest



PostSubject: 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?
Back to top Go down
blueymaddog
Administrator
Administrator
avatar

Posts : 1081
Join date : 2010-12-09
Age : 19

PostSubject: Re: efficiency   January 9th 2011, 1:07 am

nope.

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: 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
Back to top Go down
http://hackthissite.org
myrco919
Intermediate Scripter
Intermediate Scripter
avatar

Posts : 190
Join date : 2011-01-21
Age : 19
Location : Holland

PostSubject: 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
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: Re: efficiency   January 25th 2011, 11:54 pm

blueymaddog?
Back to top Go down
http://hackthissite.org
blueymaddog
Administrator
Administrator
avatar

Posts : 1081
Join date : 2010-12-09
Age : 19

PostSubject: Re: efficiency   January 26th 2011, 8:00 am

yes supernaplam?

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: 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?
Back to top Go down
http://hackthissite.org
blueymaddog
Administrator
Administrator
avatar

Posts : 1081
Join date : 2010-12-09
Age : 19

PostSubject: Re: efficiency   January 27th 2011, 8:07 am

Yes. and the ID changes all the time. Try printing the same table twice. :P

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
slayer9365
Expert Scripter
Expert Scripter
avatar

Posts : 233
Join date : 2010-07-31
Age : 22

PostSubject: Re: efficiency   January 27th 2011, 7:04 pm

It will only change if you change it.
Back to top Go down
blueymaddog
Administrator
Administrator
avatar

Posts : 1081
Join date : 2010-12-09
Age : 19

PostSubject: Re: efficiency   January 27th 2011, 8:00 pm

print _G twice. it prints different id's 0.o

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: 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
Back to top Go down
http://hackthissite.org
blueymaddog
Administrator
Administrator
avatar

Posts : 1081
Join date : 2010-12-09
Age : 19

PostSubject: Re: efficiency   January 28th 2011, 12:14 am

lolwhatiswrongwithmyscriptthatyourtryingtopointput?

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
naknak
Administrator
Administrator
avatar

Posts : 878
Join date : 2010-07-30

PostSubject: Re: efficiency   January 28th 2011, 8:55 am

Couldn't you just combine those two variables anyway? :D Felt like jumping in
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: Re: efficiency   January 28th 2011, 10:19 pm

what i think is wrong is that you accessed part instead of _.
Back to top Go down
http://hackthissite.org
blueymaddog
Administrator
Administrator
avatar

Posts : 1081
Join date : 2010-12-09
Age : 19

PostSubject: 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

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: Re: efficiency   January 29th 2011, 2:35 pm

i thought part was a key, not an index
Back to top Go down
http://hackthissite.org
blueymaddog
Administrator
Administrator
avatar

Posts : 1081
Join date : 2010-12-09
Age : 19

PostSubject: 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.

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: 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?
Back to top Go down
http://hackthissite.org
blueymaddog
Administrator
Administrator
avatar

Posts : 1081
Join date : 2010-12-09
Age : 19

PostSubject: 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.

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
Sponsored content




PostSubject: Re: efficiency   

Back to top Go down
 
efficiency
View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
A Roblox Community :: Questions and Help :: Scripting-
Jump to: