I am currently coding a light with a switch. It is inside a shed that is anchored as a union. When I move the shed so it is just the light and the switch in mid air the mechanism works perfectly but when the shed is where is should be holding the light and the switch I try to hover and click the button but it doesn't work at all. Please help T-T. Here is my code for the light if it helps. I am not that advanced.

local cd = script.Parent.ClickDetector
local on = script.Parent.Parent.On
local off = script.Parent.Parent.Off
local bright = script.Parent.Parent.Parent.Light.Lightbulb.bright
local light = script.Parent.Parent.Parent.Light.Lightbulb.bright.SpotLight

bright.Transparency = 1
on.Transparency = 1
off.Transparency = 0
light.Enabled = false

cd.MouseClick:Connect(function()
	if on.Transparency == 1 then
		on.Transparency = 0
		off.Transparency = 1
		bright.Transparency = 0
		light.Enabled = true
	elseif on.Transparency == 0 then
		on.Transparency = 1
		off.Transparency = 0
		bright.Transparency = 1
		light.Enabled = false
	end
end)

1 comment

0

It's like the shed itself is in the way of the lighting system