ok so i tried to make a lightswitch with 2 blocks that disappear and re-appear (like a lightswitch that flicks on and off), both scripts are 'connected' to the light, but when i click the 1st visible switch, nothing happens. the 2nd switch doesnt appear, 1st switch doesnt disappear, and the light doesnt turn on. (the light brick is called lightbulb1, and it has a pointlight in it) heres both scripts of both the lightswitch bricks (sorry if its so bad lol)
1st switch: (name is switch1)
script.Parent.ClickDetector.MouseClick.Connect(function(onClick) script.Parent.Parent.lightbulb1.PointLight.Enabled = true script.Parent.Transparency = 1 script.Parent.ClickDetector.MaxActivationDistance = 0 script.Parent.Parent.switch2on1.Transparency = 1 script.Parent.switch2on1.ClickDetector.MaxActivationDistance = 15 end)
2nd switch: (name is switch2on1)
script.Parent.ClickDetector.MouseClick.Connect(function(onClick) script.Parent.Parent.lightbulb1.PointLight.Enabled = false script.Parent.Transparency = 1 script.Parent.ClickDetector.MaxActivationDistance = 0 script.Parent.Parent.switch1.Transparency = 0 script.Parent.Parent.switch1.ClickDetector.MaxActivationDistance = 15 end)
if u can help, thx!!
The only thing you did wrong was the period in front the "Connect". Needs to be a colon. Also, I left a comment, please read.
If this helped, please be sure to accept my answer :)
script.Parent.ClickDetector.MouseClick:Connect(function(Player) --You use a " : " to connect, not a " . ". Also, the parameter for MouseClick is the Player. script.Parent.Parent.lightbulb1.PointLight.Enabled = true script.Parent.Transparency = 1 script.Parent.ClickDetector.MaxActivationDistance = 0 script.Parent.Parent.switch2on1.Transparency = 1 script.Parent.switch2on1.ClickDetector.MaxActivationDistance = 15 end)