Why won't this simple code work? It keeps teleporting Switch up a stud. idk why.
local xori = script.Parent.Switch.Orientation.X local yori = script.Parent.Switch.Orientation.Y local zori = script.Parent.Switch.Orientation.Z function onClicked() if script.Parent.Switch.Orientation.Z == 90 then script.Parent.Parent.CeilingLight.Light.SurfaceLight.Brightness = 0 script.Parent.Switch.Orientation = Vector3.new(xori, yori, zori + 4) else script.Parent.Parent.CeilingLight.Light.SurfaceLight.Brightness = 3 script.Parent.Switch.Orientation = Vector3.new(xori, yori, zori) end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
local Light = script.Parent.Parent.CeilingLight.Light.SurfaceLight local Switch = script.Parent.Switch local on, off = Switch.CFrame * CFrame.Angles(0, 0, math.rad(2)), Switch.CFrame * CFrame.Angles(0, 0, -math.rad(2)) local function onClicked() if Light.Brightness == 3 then Light.Brightness = 0 Switch.CFrame = on else Light.Brightness = 3 Switch.CFrame = off end end script.Parent.ClickDetector.MouseClick:Connect(onClicked)