Why is thus happening? The doors should move different directions

Heya! I’m lcey. Tiny developer. Currently working on a project called Area 53, I need help on a door script of mine that involves cframe things. Lookvector to be specific. If you could please take a look, and maybe solve my issue. That’d be chill.

So there is two mesh doors. Door1 (left), and Door2 (right). They’re supposed to go separate ways for 5s, then stop. Yet they go out for 5s, then stop. Screenshot;

I’ve tried rightVector, yet it only did the same thing! Tried asking friends, they tried a way idk, then said they “were unable to do it, too hard”. So I figured I’d come here.

Source code:

local LeftDoor = script.Parent.Door2
local RightDoor = script.Parent.Door1
local prox1 = script.Parent.Parent.Keycard1.Union
local prox2 = script.Parent.Parent.Keycard2.Union
local Open = false

local plr = game:GetService("Players").LocalPlayer
--local teamserv = game:GetService("Teams")

local OpenSound = RightDoor.DoorOpen
local CloseSound = RightDoor.DoorClose
local beep = RightDoor.Beep

local Debounce = false
function proxused(plr)
	if not Debounce then
		Debounce = true
			if Open then
				Open = false
				prox1.ProximityPrompt.ActionText = "Open"
				prox2.ProximityPrompt.ActionText = "Open"            
				CloseSound:Play()
				beep:play()
				spawn(function()
					for i = 1, 60 do
						LeftDoor.CFrame = LeftDoor.CFrame + (LeftDoor.CFrame.LookVector * 0.1)
						wait(0.05)
					end
				end)
				spawn(function()
					for i = 1, 60 do
						RightDoor.CFrame = RightDoor.CFrame + (RightDoor.CFrame.LookVector * 0.1)
						wait(0.05)
					end
				end)
			else
				Open = true
				OpenSound:Play()
				beep:play()
				prox1.ProximityPrompt.ActionText = "Close"
				prox2.ProximityPrompt.ActionText = "Close"    
				spawn(function()
					for i = 1, 60 do
						LeftDoor.CFrame = LeftDoor.CFrame - (LeftDoor.CFrame.lookVector * 0.1)
						wait(0.05)
					end
				end)
				spawn(function()
					for i = 1, 60 do
						RightDoor.CFrame = RightDoor.CFrame - (RightDoor.CFrame.lookVector * 0.1)
						wait(0.05)
					end
				end)
			end
			wait(3)
			Debounce = false
		end
	end
prox1.ProximityPrompt.Triggered:Connect(proxused)
prox2.ProximityPrompt.Triggered:Connect(proxused)

If you could please help me, that’d be great. I’m kinda stumped. My main type category is modeling, not scripting.
-lcey

4 Likes

LookVector is based on its front/back face of the mesh.
Positive would move it forward negative would be backwards. There’s an upvector, it’s the same thing but for up and down.

What you’re looking for us rightvector instead of lookvector. So change “lookvector” with “rightvector” and if you want a door to go the opposite direction just make your positive value negative or vice versa.

5 Likes

Is positive *, and negative -?

2 Likes

positive would be * .1 and negative would be * -.1

2 Likes

I found that found on my own the second I asked that. Thank you though!

1 Like

I appreciate you 100%, thank you man!

4 Likes

You should try tweens, its a lot easier then doing a for loop and looks smoother

1 Like

It also saves a huge pain with scripts like these.

2 Likes

Thank you, yet this hallway is done! Spade helped me a ton.

Quick showcase from the bus xd :joy: