local lights = game.Workspace.Interactables.Switches:GetChildren()
function keydown(k)
if k:lower() == "e" and ((script.Parent.Parent.Character.Torso.Position - lights.Position).magnitude) < 2.25 then
for a, aa in pairs(game.Workspace.Interactables.Lights:FindFirstChild(lights.Name):GetChildren()) do
if aa.Light.Brightness == 0 then
aa.Light.Brightness = 1000
else
aa.Light.Brightness = 0
end
end
end
end
local m = script.Parent.Parent:GetMouse()
m.KeyDown:connect(keydown)
What I'm trying to do is well. I have a lot of light switches and I'm trying to avoid using a billion scripts (one in each lightswitch) and use one local script in starter pack. I'm not sure how to make it work with every light switch? And also. This script does NOT work. and when it was working with one lightswitch it did NOT work online.

3 comments
You seem to be getting the position of the table "lights". Do you mean to try each one? Also, are there any errors given?
No errors. But I want to check if the magnitude of them and the torso is 2.25
Would it be easier to set the brightness to 1000 in studio and alter the enabled property?