A Roblox Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

A Roblox Community

A community of Robloxians who want to learn to script and build on Roblox Studio.
 
HomeLatest imagesRegisterLog 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
efficiency Vote_lcapefficiency Voting_barefficiency Vote_rcap 
naknak
efficiency Vote_lcapefficiency Voting_barefficiency Vote_rcap 
Supernapalm
efficiency Vote_lcapefficiency Voting_barefficiency Vote_rcap 
m27frogy
efficiency Vote_lcapefficiency Voting_barefficiency Vote_rcap 
slayer9365
efficiency Vote_lcapefficiency Voting_barefficiency Vote_rcap 
myrco919
efficiency Vote_lcapefficiency Voting_barefficiency Vote_rcap 
branefreez
efficiency Vote_lcapefficiency Voting_barefficiency Vote_rcap 
ninga95
efficiency Vote_lcapefficiency Voting_barefficiency Vote_rcap 
CloneTrooper787
efficiency Vote_lcapefficiency Voting_barefficiency Vote_rcap 
raboy117
efficiency Vote_lcapefficiency Voting_barefficiency Vote_rcap 
Top posting users this month
No user
Latest topics
» Where to go from here.
efficiency EmptySeptember 14th 2020, 1:20 pm by MrNicNac

» Send me an Email
efficiency EmptySeptember 14th 2020, 1:16 pm by MrNicNac

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


 

 efficiency

Go down 
5 posters
AuthorMessage
Guest
Guest
avatar



efficiency Empty
PostSubject: efficiency   efficiency EmptyJanuary 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
blueymaddog


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

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 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
avatar



efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 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
blueymaddog


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

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 9th 2011, 1:07 am

nope.
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 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
myrco919


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

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 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
avatar


Posts : 393
Join date : 2011-01-17

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 25th 2011, 11:54 pm

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


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

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 26th 2011, 8:00 am

yes supernaplam?
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 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
blueymaddog


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

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 27th 2011, 8:07 am

Yes. and the ID changes all the time. Try printing the same table twice. :P
Back to top Go down
slayer9365
Expert Scripter
Expert Scripter
slayer9365


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

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 27th 2011, 7:04 pm

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


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

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 27th 2011, 8:00 pm

print _G twice. it prints different id's 0.o
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 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
blueymaddog


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

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 28th 2011, 12:14 am

lolwhatiswrongwithmyscriptthatyourtryingtopointput?
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 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
avatar


Posts : 393
Join date : 2011-01-17

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 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
blueymaddog


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

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 29th 2011, 6:36 am

mine is fine. for [name of the index it's iriterating through], key in ipairs(table) do
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 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
blueymaddog


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

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 30th 2011, 6:48 am

key is the value index is the name of where the key is stored in the table.
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyJanuary 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
blueymaddog


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

efficiency Empty
PostSubject: Re: efficiency   efficiency EmptyFebruary 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.
Back to top Go down
Sponsored content





efficiency Empty
PostSubject: Re: efficiency   efficiency Empty

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