I want it so my door SLIDES to the right (when you are facing the door) and when you click it again, it slides back, click it again slides to the right and so on. However, my script makes my door rotate 90 degrees then breaks. It does not rotate back when you click it again. Here is my script
local brick = script.Parent.brick local c = true function OnC() if c == true then c = false brick.CFrame = CFrame.new(-39.2, 4.69, -53.3) end if c == false then c = true brick.CFrame = CFrame.new(-39.2, 4.69, -46.8) end end brick.ClickDetector.MouseClick:connect(OnC)
What is wrong with it?
local brick = script.Parent.brick local c = true function OnC() if c == true then c = false brick.CFrame = CFrame.new(-39.2, 4.69, -53.3) -- the end was here, it shouldn't have been. elseif c == false then -- changed this to elseif c = true brick.CFrame = CFrame.new(-39.2, 4.69, -46.8) end end brick.ClickDetector.MouseClick:connect(OnC)
What was wrong is that you had an end.. and you didn't do an elseif.. So it only processed the first part.