1 script for multiple bricks - ClickDetector for Spotlights. Why doesn't it work in my place?
So I am having an issue with my script, and I have done all I could to solve it. What I want to do is create a function that turns on multiple lights with a simple on and off switch.
1 | script.Parent.ClickDetector.MouseClick:connect( function () |
2 | for _,Part in pairs (workspace.Lights.CL:GetChildren()) do |
3 | if Part:FindFirstChild( "SpotLight" ) then |
4 | Part.SpotLight.Enabled = true |
So this is what I've done to troubleshoot with no success:
-- I've tried to change the names of the models I used them for.
-- I've deleted the Part/Model and recreated it.
What is interesting, however:
-- It works in studio mode > Play here with other places/games.
-- It works if I paste the code and write in the name for each Part/Model (which is a waste of time).
Any help? I'm still learning to code, so any help I can get would be useful. thank you!