game = Click light0
game = Click light10
Part:Do
✓ ANSWER ACCEPTED
How to make a light switch go on and off?
1 answer
✓ Accepted answer
So this is written from a tablet sooooo stick with me here.
-- put this script in the part you want to be clicked on to enable the light
local Light = script.Parent.Parent.SurfaceLight -- the light
local Activation_Distance = 10 -- how many studs away it can be activated
local clicker = Instance.new("ClickDetector")
clicker.Parent = script.Parent
clicker.MaxActivationDistance = Activation_Distance
local db = false
clicker.MouseClick:Connect(function()
if not db then -- if the variable (db) is false
light.Enabled = true -- enable the light
else -- if the variable (db) is true
light.Enabled = false -- disable the light
end
db = not db -- make the variable (db) the opposite of itself
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
This code makes me smile
What you are looking for: https://developer.roblox.com/en-us/api-reference/event/ClickDetector/MouseClick