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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Shortening this script piece.

Previous Thread :: Next Thread 
Krelinos is not online. Krelinos
Joined: 09 Jan 2010
Total Posts: 425
24 Jan 2013 09:18 PM
if percent < 0.75 then
part.BackSurface = "Studs"
part.BottomSurface = "Studs"
part.FrontSurface = "Studs"
part.LeftSurface = "Studs"
part.RightSurface = "Studs"
part.TopSurface = "Studs"
end

I want to shorten the surface changing lines, how would I do that?
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
24 Jan 2013 09:20 PM
Make the brick smaller?

Fail: http://www.roblox.com/qwe543fdhg45y-item?id=24975956
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
24 Jan 2013 09:21 PM
If you are doing this often throughout a script i would just make a function for it...
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
24 Jan 2013 09:23 PM
You really shouldn't worry about making properties more efficient when you assign them
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
24 Jan 2013 09:23 PM
God, I'm stupid. Anyway, yeah I would use a function.

Fail: http://www.roblox.com/qwe543fdhg45y-item?id=24975956
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
24 Jan 2013 09:23 PM
if percent < 0.75 then
_G.SetSurfaces(part,"studs")

end



_G.SetSurfaces(thing,what)
thing.BackSurface = what
thing.BottomSurface = what
thing.FrontSurface = what
thing.LeftSurface = what
thing.RightSurface = what
thing.TopSurface = what
end
Report Abuse
Krelinos is not online. Krelinos
Joined: 09 Jan 2010
Total Posts: 425
24 Jan 2013 09:24 PM
No. I want to change it so instead of changing each surface one by one, it will only need one line for each surface(for loop?).
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
24 Jan 2013 09:24 PM
wait...nevermind...
Report Abuse
Krelinos is not online. Krelinos
Joined: 09 Jan 2010
Total Posts: 425
24 Jan 2013 09:25 PM
Oh man, that's a lot of replies before that last one came out.

Alright, I'll do a function. Thanks.
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
24 Jan 2013 09:46 PM
local p = {"Back","Bottom","Front","Left","Right","Top"}
if percent < 0.75 then
for i,v in pairs(p) do
loadstring("part."..v.."=Enum.SurfaceType.Studs")
end end

ha, shorter, yet less efficient c:
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