script.Parent.MouseClick:Connect(function() local roof = script.Parent.Parent.Parent.Parent.Roof if roof.LightToggle.Value == true then script.Parent.Parent.CFrame = script.Parent.Parent.CFrame * CFrame.new(-21.9, 4.642, 17.77) * CFrame.Angles(0, math.rad(90), math.rad(138.23)) for a, b in pairs(roof:GetChildren()) do if b.Name == ("Light") then b.PointLight.Enabled = false b.Material = Enum.Material.Plastic end end roof.LightToggle.Value = false elseif roof.LightToggle.Value == false then script.Parent.Parent.CFrame = script.Parent.Parent.CFrame * CFrame.new(-21.9, 4.642, 17.77) * CFrame.Angles(0, math.rad(90), math.rad(-126.43)) for a, b in pairs(roof:GetChildren()) do if b.Name == ("Light") then b.PointLight.Enabled = true b.Material = Enum.Material.Neon end end roof.LightToggle.Value = true end end)
so this is a light switch that's supposed to flip up and down and turn the lights on and off. the lights work perfectly except the switch disappears after i click it once. any help?
Found 2 errors related to math.rad in the code. Here's the script:
script.Parent.MouseClick:Connect(function() local roof = script.Parent.Parent.Parent.Parent.Roof if roof.LightToggle.Value == true then script.Parent.Parent.CFrame = script.Parent.Parent.CFrame * CFrame.new(-21.9, 4.642, 17.77) * CFrame.Angles(math.rad(0), math.rad(90), math.rad(138.23)) for a, b in pairs(roof:GetChildren()) do if b.Name == ("Light") then b.PointLight.Enabled = false b.Material = Enum.Material.Plastic end end roof.LightToggle.Value = false elseif roof.LightToggle.Value == false then script.Parent.Parent.CFrame = script.Parent.Parent.CFrame * CFrame.new(-21.9, 4.642, 17.77) * CFrame.Angles(math.rad(0), math.rad(90), math.rad(-126.43)) for a, b in pairs(roof:GetChildren()) do if b.Name == ("Light") then b.PointLight.Enabled = true b.Material = Enum.Material.Neon end end roof.LightToggle.Value = true end end)