i do know the visual difference of these two light types but i am trying to make a lightswitch for my surface light and it’s saying this. i previously tried with a pointlight for practice, and it worked just fine. is there a way i could go around this or would i really need pointlights?
Can you send your code? Seems like your MouseClick Function is coded wrong
I presume you’re trying to turn on and off a light by clicking on something? If so, you need to utilize the MouseClick
event on a ClickDetector
, and not the light itself.
More info can be found on the following Developer Hub page:
light = script.Parent.Parent.Parent.bulb – do not change light anywhere in this script light is not a part
switchy = script.Parent.Parent – do this for the switch part
function onClick() – theres a function
if light.lightforswitch.Enabled == false then – if the pointlight obj isn’t on
light.lightforswitch.Enabled = true – then turn it on
else light.lightforswitch.Enabled = false -- this makes it be able to do it more than once
end
end
script.Parent.MouseClick:Connect(onClick) – calling the function
i wrote notes in there to keep track, im new at this lol
i do have a ClickDetector in the switch part.
If you’re trying to fix your code, Can I see the explorer?

the parent of the model the light is in is the workspace, and that is also the case for the switchy.
You are using the MouseClick event on the light instead of the click detector.
You index the pointlight instead of the click detector, moving your script causes an error. Your model is not sorted so it’s harder so I recommend you sorting it.
To know how Parents work, parent is the property of the object and it exists on every object, and to index to your click detector via parent in you’re explorer, you have to use parents if it’s a child, until if you’re at the object that contains the part with the pointlight, then you can start going down to the names like game.workspace.Light
If you want me to manually fix the code, then I want you to screenshot the whole thing instead of 2 screenshots because I’m confused with the screenshot.
yes, just a second while i get it in the same place
unfortunately i do not have anymore time for this today. i’ll pick it back up at the earliest i can tomorrow, but thank you for your help for now though!
Name the surfacelight “lightforswitch” and it should be fine.
Alternatively, do “script.Parent”, that would also improve performance a bit.
local ClickDetector = -- Make a script in the click detector that way you
-- can do script.Parent
local Light = -- Find where the light is
ClickDetector.MouseClick:Connect(function()
Light.Enabled = not Light.Enabled
end)
Hope this helps!
SurfaceLight means it applies a light that’s originate from a surface. PointLight means it will apply a light that is originate from a point. If you Parent this to a BasePart or Attachment, the origination position will be the position of both instance.
oh my goodness… wow the script was in the surfacelight the whole time. haha thank you! i need to put it in the clickdetector lol