Hi there! Im currently in the process of making a game and I need a script that allows me to click a button which changes the colour of a light that the button is assigned to. I am a bit confused as to what I need to do to make it work because i have tried altering my code multiple times and every time it hasnt worked. I would really appreciate some help because I have tried everything I can and I have not been able to get it to work.
Here is the code I have so far
local clickdetector = script.Parent:WaitForChild(“ClickDetector”)
clickdetector.MouseClick:Connect(function(player)
game.Workspace.pinkLight.Surfacelight.Color = BrickColor.new("Pink").Color
end)
(pinkLight is the name of the light i want to change the color of)

10 comments
Hi! Thanks a lot for you help. So would i put this in the button and then link that to a remote event? Also would this work if i wanted to control the light when the button is a different block?
Oh you can put this in a normal script. If you wanted to control the light remotely, I'll edit my answer.
Yeah thats what i want it to do so that would be very helpful :)
Done! If you have any further questions, do ask.
Thank you so much for your help!
No problem :)
Alright, i still cant get it to work. Do each parts of the script go in different scripts? Like for example the first part would go in the buttons script and the second part would go in the lights script?
No, keep all code in one script.
Hi again. I still cant get it to work. Would it be possible to contact on discord so i can show you what im doing in more detail so you can show me where im going wrong?
Sure. Incompetence#8077