Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Elevator door's CFrame not being changed when told to?

So first step in coding an elevator is the doors automatically moving. One of my door(door1) moves, but the other one doesn't budge(door2). Please help?

debounce = true
script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and debounce then
		debounce = false
		for moved1 = 933.301, 939.111, 0.5 do
			game.Workspace.Door1.CFrame = CFrame.new(Vector3.new(moved1, 4.642, -386.874))
			wait(0.1)
		end
		for moved2 = 926.038, 920.378, 0.5 do
			game.Workspace.Door2.CFrame = CFrame.new(Vector3.new(moved2, 4.642, -386.874))
		end
	end
end)

some lines of the script were too long to fit in the code block so that's why some lines of code run on into the next line.

1 answer

✓ Accepted answer
for moved2 = 926.038, 920.378, 0.5 do

Your start number is greater than your end number, but you have a positive increment. So basically you're trying to go from 926 to 920 by adding 0.5 each time. Just make the increment negative.

for moved2 = 926.038, 920.378, -0.5 do

This should work.

But seriously, dude... your code is a mess lol. Just add to the CFrame, don't use exact coordinates. This will also let you move the doors wherever you want and they should still work.

local door1 = workspace.Door1

for i = 1, 5 do
	door1.CFrame = door1.CFrame * CFrame.new(0.5, 0, 0)
end

Also remember that you never set your debounce back to true.

3 comments

0

thank you so much, but what would i do for door2 to move the opposite way?

0

nvm, i figured it out

0

yeah it's just -0.5 instead of 0.5.

This discussion is preserved as it was. New answers, comments, and votes are closed.