How can i make a script that will turn on lights in order so that the ones closest to the part turn on first and the ones furthest away turn on last?
Put all the lights in a folder, and number them from 1 to the amount of lights.
Then you can use a loop to go through the lights from the folder and turn each one on in order.
A loop like this for example:
folder = workspace.Folder
for i = 1, #folder:GetChildren() do
folder[tostring(i)].LightPart.Enabled = true
wait(0.2)
end
3 Likes
You can check the distance from each lamp using (Part.Position - Light.Position).Magnitude
Loop through each light and for each light, check it’s distance from the part, then compare that to the other lights. If a closer part is found, cancel, if not, turn it on and wait, then set a value to exclude it from other calculations and try the next.
Something like that, I can’t think of a working version off the top of my head but maybe a while loop to do it until they’re all on.
1 Like
This is not what i need i said it has to be from the position