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
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Lights won't turn off >.>

Previous Thread :: Next Thread 
bealot is not online. 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 is not online. 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
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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 is not online. bealot
Joined: 25 Sep 2012
Total Posts: 105
12 Feb 2017 08:03 AM
Ooooh damn, I'm so stupid. Thanks man.


Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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 is not online. 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
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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 is not online. bealot
Joined: 25 Sep 2012
Total Posts: 105
12 Feb 2017 08:04 AM
New censorship or Roblox eh, like it? :P


Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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 is not online. bealot
Joined: 25 Sep 2012
Total Posts: 105
12 Feb 2017 08:33 AM
Well, thanks for that, appreciate it.


Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
12 Feb 2017 09:19 AM
Materials can use strings?

I thought they only used enumerations.
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
12 Feb 2017 01:23 PM
they do, but all strings are converted into enums when you are setting an enum property
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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