of     1   

SpazzMan502
#139456039Sunday, July 06, 2014 9:11 PM GMT

So im still a beginner scripter, i know most of lua, and i script some things. but, i seriously don't think scripts should look like that Im making. This is what I mean: (It works tho) function onClick() game.Workspace.Light1.Bulb1.PointLight.Enabled = true game.Workspace.Light2.Bulb2.PointLight.Enabled = true wait(0.65) game.Workspace.Light3.Bulb3.PointLight.Enabled = true game.Workspace.Light4.Bulb4.PointLight.Enabled = true wait(0.65) game.Workspace.Light5.Bulb5.PointLight.Enabled = true game.Workspace.Light6.Bulb6.PointLight.Enabled = true end script.Parent.ClickDetector.MouseClick:connect(onClick) I know i can use something using 'local' but i don't know how... can anyone give me an explanation or something? Thanks in advance.
ScottRhode
#139456598Sunday, July 06, 2014 9:17 PM GMT

well, you can't make it simpler, only shorter. to make it shorter, you can make an table and have code run trough it lights = {game.Workspace.Light1.Bulb1.PointLight.Enabled,game.Workspace.Light2.Bulb2.PointLight.Enabled,game.Workspace.Light3.Bulb3.PointLight.Enabled,game.Workspace.Light4.Bulb4.PointLight.Enabled,game.Workspace.Light5.Bulb5.PointLight.Enabled, game.Workspace.Light6.Bulb6.PointLight.Enabled} for i,v in ipairs(lights) do lights[i].Enabled = true wait(0.65) end
ScottRhode
#139456652Sunday, July 06, 2014 9:17 PM GMT

however, actually the way you code is fine.
SpazzMan502
#139456706Sunday, July 06, 2014 9:18 PM GMT

i was looking for a general idea how to do something using local, im not sure exactly what it means and how i use it...
ScottRhode
#139456864Sunday, July 06, 2014 9:19 PM GMT

with local, you give something a shorter name and then use the short name. it doesn't make your script any simpler though. local light1 = game.Workspace.Light1.PointLight1.Enabled light1.Enabled = true really. in your case it doesnt make the script any simpler.
SpazzMan502
#139457106Sunday, July 06, 2014 9:22 PM GMT

oh, so its like giving a different name to it, like so i don't have to type game.workspace.light.whatever good.
nobbers12345
#139458155Sunday, July 06, 2014 9:33 PM GMT

Actually, local changes what scope can be used. a = 5 function Stuff() local a = 3 print (a) ----Returns 3 if true then local a = 2 print (a) ----Returns 2 end end print(a) ---- Returns 5 I hate the LGBT. Those laser guided battle tanks are just too damn powerful.

    of     1