Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a script to change the brightness of 102 spotlights?

I know how to make a script to handle 1 light, but 102 without having to make a long inefficient script... I've tried pretty much everything I know but nothing seems to work. Does anyone here know how to make that light switch toggle all those at once?

3 comments

0

possibly move them all into a folder or model and do something with children

1

A script is only inefficient if there is a faster way to do it. Inefficient does not mean slow. To change the brightness of 102 spotlights, you have to set the brightness of 102 spotlights individually. There is no magical alternative. I doesn't need to be a long script, it's 3 lines of code (1 without whitespace).

0

Ya I did a answer :DD

1 answer

Makes the light's name become etc: Light1 ,Light2 ,Light3 ,Light4... Until Light102

and enter this script

local int = Instance.new("IntValue",workspace) -- make a IntValue

int.Value = 1
HowMuchLights = 102 -- how many light you have

repeat -- repeat and repeat until int.Value > HowMuchLights
	game.Workspace["Light"..int.Value].SpotLight.Brightness = 10 -- make every lights  become brightness 10
	int.Value = int.Value + 1
until int.Value > HowMuchLights  -- dont give server search Light103 and moderated OR freeze your Roblox Studio

Hope I helped, happy coding! :D

:)

1 comment

0

This wont not be effective. Imagine having 1k lights. You would have to change each of the light's name to it's own number... It would take forever.

This discussion is preserved as it was. New answers, comments, and votes are closed.