Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a lightswitch?

I want to click in a part and whean I click it, I want another part to light. I'm kinda noob with scripting so can someone help me?

1 answer

✓ Accepted answer

Put a ClickDetector inside of the Part and this script as a descendant of the Part as well. Make sure it's a PointLight. If not, I'm sure you can modify this.

on = false
script.Parent.ClickDetector.MouseClick:connect(function()
	if on == false then
		on = true
		script.Parent.PointLight.Enabled = true
	else
		on = false
		script.Parent.PointLight.Enabled = false
	end
end)

2 comments

0

Thank you very much, I didn't wanted to click in the light to turn it on and off, I wanted to click in an interrupter so it can turn the light on and off, but I changed some things in the script you send and it works :D Thanks a lot!

0

Glad I could help

This discussion is preserved as it was. New answers, comments, and votes are closed.