bealot
|
  |
| Joined: 25 Sep 2012 |
| Total Posts: 105 |
|
|
| 12 Feb 2017 08:00 AM |
I got the following script, for turning off multiple lights and changing their material BUT, I have a problem. Lights 3,4 and 5 don't turn off, neither does their material change. Anyone knows the problem?
function onTouch(JumpscareBrick8) game.Workspace.Light1.SurfaceLight:Destroy() game.Workspace.Light1.Material = "SmoothPlastic" game.Workspace.Light2.SurfaceLight:Destroy() game.Workspace.Light2.Material = "SmoothPlastic" game.Workspace.Light2.SurfaceLight.Enabled = false game.Workspace.Light2.Material = "SmoothPlastic" game.Workspace.Light3.SurfaceLight:Destroy() game.Workspace.Light3.SurfaceLight.Enabled = false game.Workspace.Light3.Material = "SmoothPlastic" game.Workspace.Light4.SurfaceLight:Destroy() game.Workspace.Light4.Material = "SmoothPlastic" game.Workspace.Light5.SurfaceLight:Destroy() game.Workspace.Light5.Material = "SmoothPlastic" game.Workspace.Light6.SurfaceLight:Destroy() game.Workspace.Light6.Material = "SmoothPlastic" game.Workspace.Light6.Script:Destroy() game.Workspace.Light7.SurfaceLight:Destroy() game.Workspace.Light7.Material = "SmoothPlastic" game.Workspace.Light8.SurfaceLight:Destroy() game.Workspace.Light8.Material = "SmoothPlastic" game.Workspace.Light9.SurfaceLight:Destroy() game.Workspace.Light9.Material = "SmoothPlastic" game.Workspace.Light9.Script:Destroy() game.Workspace.Light10.SurfaceLight:Destroy() game.Workspace.Light10.Material = "SmoothPlastic" game.Workspace.Light11.SurfaceLight:Destroy() game.Workspace.Light11.Material = "SmoothPlastic" game.Workspace.Light12.SurfaceLight:Destroy() game.Workspace.Light12.Material = "SmoothPlastic" game.Workspace.Light12.Script:Destroy() game.Workspace.Light13.SurfaceLight:Destroy() game.Workspace.Light13.Material = "SmoothPlastic" game.Workspace.Light14.SurfaceLight:Destroy() game.Workspace.Light14.Material = "SmoothPlastic" end
script.Parent.Touched:connect(onTouch)
|
|
|
| Report Abuse |
|
|
Versault
|
  |
| Joined: 08 Oct 2014 |
| Total Posts: 3241 |
|
|
| 12 Feb 2017 08:01 AM |
game.Workspace.Light3.SurfaceLight:Destroy() game.Workspace.Light3.SurfaceLight.Enabled = false -- Why? you already destroyed it. game.Workspace.Light3.Material = "SmoothPlastic" |
|
|
| Report Abuse |
|
|
|
| 12 Feb 2017 08:02 AM |
| holy heck for loops local lights = ######################## for ## light in ipairs( lightmodel ) do light.SurfaceLight.Enabled = false light.Material = "SmoothPlastic" end |
|
|
| Report Abuse |
|
|
bealot
|
  |
| Joined: 25 Sep 2012 |
| Total Posts: 105 |
|
|
| 12 Feb 2017 08:03 AM |
Ooooh damn, I'm so stupid. Thanks man.
|
|
|
| Report Abuse |
|
|
|
| 12 Feb 2017 08:03 AM |
| holy heck for loops local lights = ######################### for ## light in ipairs( lights ) do light.SurfaceLight.Enabled = false light.Material = "SmoothPlastic" end |
|
|
| Report Abuse |
|
|
bealot
|
  |
| Joined: 25 Sep 2012 |
| Total Posts: 105 |
|
|
| 12 Feb 2017 08:03 AM |
@Wunder_Wulfe, I'm just a really basic scripter, didn't knew that.
|
|
|
| Report Abuse |
|
|
|
| 12 Feb 2017 08:03 AM |
nevermind, just use for loops
i put it in preview and it got censored still but only when i posted it |
|
|
| Report Abuse |
|
|
bealot
|
  |
| Joined: 25 Sep 2012 |
| Total Posts: 105 |
|
|
| 12 Feb 2017 08:04 AM |
New censorship or Roblox eh, like it? :P
|
|
|
| Report Abuse |
|
|
|
| 12 Feb 2017 08:05 AM |
for _, light in ipairs( Model:getChildren() ) do light.Enabled, light.Material = false, "SmoothPlastic" end
basically will iterate through the children of the model and apply that for each one |
|
|
| Report Abuse |
|
|
|
| 12 Feb 2017 08:07 AM |
| just toss all your lights into # folder or model and it will condense your stuff into # miniature script with more easily modifiable changes if you are interested in learning how to use for loops, check the wikis or tutorials on youtube |
|
|
| Report Abuse |
|
|
bealot
|
  |
| Joined: 25 Sep 2012 |
| Total Posts: 105 |
|
|
| 12 Feb 2017 08:33 AM |
Well, thanks for that, appreciate it.
|
|
|
| Report Abuse |
|
|
|
| 12 Feb 2017 09:19 AM |
Materials can use strings?
I thought they only used enumerations. |
|
|
| Report Abuse |
|
|
|
| 12 Feb 2017 01:23 PM |
| they do, but all strings are converted into enums when you are setting an enum property |
|
|
| Report Abuse |
|
|