local plr = game.Players.LocalPlayer
function onKeyDown(key, mouse)
if key:lower() == "e" and ((game.Players.Player1.Character.Torso.Position - game.Workspace.Interactables.Switches.AA.Position).magnitude) < 100 then
local lightName = "AA"
for i, aa in pairs(game.Workspace.Interactables.Lights:FindFirstChild(lightName):GetChildren()) do
if aa:FindFirstChild("Light").Brightness == 1000 then
aa:FindFirstChild("Light").Brightness = 0
else
aa:FindFirstChild("Light").Brightness = 1000
end
end
end
end
mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
Trying to get this to work when you push E and you are close enough to the button it'll turn off the lights. No output and doesn't even print 1. Its in a localscript in starterpack
Edited!

1 comment
The magnitude works for sure.