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:
01 | local doorOpen = false |
02 | local Keycards = { |
03 | 'Staff Card' |
04 | } |
05 |
06 | script.Parent.Touched:Connect( function (hit) |
07 | for i, v in pairs (Keycards) do |
08 | if hit.Parent.Name = = v then |
09 | if doorOpen = = false then |
10 | while script.Parent.Parent.Door.Position ~ = Vector 3. new( 2.75 , 3.6 , - 7.5 ) do |
11 | script.Parent.Parent.Door.CFrame = CFrame.new(script.Parent.Parent.Door.Position - Vector 3. new( 0 , 0 , 0.1 )) |
12 | wait( 0.01 ) |
13 | end |
14 | elseif doorOpen = = true then |
15 | while script.Parent.Parent.Door.Position ~ = Vector 3. new( 2.75 , 3.6 , - 3 ) do |
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.