Hi. I am making a game and have tried to make a door but it will not stop opening. It just flies off into the distance. Here is my code:
local doorOpen = false local Keycards = { 'Staff Card' } script.Parent.Touched:Connect(function(hit) for i, v in pairs(Keycards) do if hit.Parent.Name == v then if doorOpen == false then while script.Parent.Parent.Door.Position ~= Vector3.new(2.75, 3.6, -7.5) do script.Parent.Parent.Door.CFrame = CFrame.new(script.Parent.Parent.Door.Position - Vector3.new(0, 0, 0.1)) wait(0.01) end elseif doorOpen == true then while script.Parent.Parent.Door.Position ~= Vector3.new(2.75, 3.6, -3) do script.Parent.Parent.Door.CFrame = CFrame.new(script.Parent.Parent.Door.Position + Vector3.new(0, 0, 0.1)) wait(0.01) end end end end end)
Nobody seems to understand simple english, so I am closing this question.
So i believe you were trying to make a sliding door. If so then. I don't know exactly where your problem is, but think it's somewhere along the lines of using a 'while'.
I've made one myself and it's working. Without 'while' or anything. Just set the CFrame into yourDoor.CFrame + Vector3.new(wherever you want it to slide). Well I actually wanted to provide you my code but since you said you're closing this question then I'm gonna end it here.