Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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?

0
possibly move them all into a folder or model and do something with children theoreticais 0 — 4y
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). EmilyBendsSpace 1025 — 4y
0
Ya I did a answer :DD Xapelize 2658 — 4y

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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

:)

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. XviperIink 428 — 4y
Ad

Answer this question