Elevator not working

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a working function elevator with moving doors, and a moving little piece at the bottom to act as a plateau for people to enter, otherwise called a shaft.
  2. What is the issue? Include screenshots / videos if possible!
    The problem is the elevator isn’t synchronized, it’s not working one after the other. When i’m tweening the plateau/shaft and the doors, it’s not moving with the elevator, it’s staying in place.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried using debounces, local functions, attributes, and etc but none have worked for me. In the output it shows that the elevator tween and the elevator plateau/shaft closing completes twice, meaning i’m triggering it to tween twice.

Module for elevator:

move = function(elevator,area,elevatorgoals, left, right, rightgoal, leftgoal, shaft, backgoal, rightcenter, leftcenter, frontgoal)
		print("Moved")
		local goalstable = {
			elevatorgoals:FindFirstChild("Goal3"),
			elevatorgoals:FindFirstChild("Goal2"),
			elevatorgoals:FindFirstChild("Goal1")
		}
		local infogen = TweenInfo.new(
			3,
			Enum.EasingStyle.Linear,
			Enum.EasingDirection.Out,
			0,
			false,
			0
		)
		if area.Position == goalstable[1].Position then
			print("Success")
			--Moving elevator
			local randomnumber = math.random(4,7)
			local infoelevator = TweenInfo.new(
				randomnumber,
				Enum.EasingStyle.Linear,
				Enum.EasingDirection.Out,
				0,
				false,
				0
			)
			--first tweens
			local closeshaft = TS:Create(shaft,infogen,{CFrame = backgoal.CFrame})
			local closeleft = TS:Create(left, infogen, {CFrame = leftcenter.CFrame})
			local closeright = TS:Create(right, infogen, {CFrame = rightcenter.CFrame})
			--second tween
			local maintween = TS:Create(area, infoelevator, {CFrame = goalstable[2].CFrame})
			--last tween
			local tween1 = TS:Create(left, infogen, {CFrame = leftgoal.CFrame})
			local tween2 = TS:Create(right, infogen, {CFrame = rightgoal.CFrame})
			local tween3 = TS:Create(shaft,infogen,{CFrame = frontgoal.CFrame})
			maintween.Completed:Connect(function()
				print("maintween completed")
				tween1:Play()
				tween2:Play()
				tween3:Play()
			end)
			closeshaft.Completed:Connect(function()
				print("closeshaft completed")
				maintween:Play()
			end)
			closeshaft:Play()
			closeleft:Play()
			closeright:Play()
		end
	end,

Part of the local script I’m using to handle the tweens:

local debounce1 = false
local debounce2 = false
inside.Touched:Connect(function()
	local attribute1 = outside:GetAttribute("Activated")
	local attribute2 = inside:GetAttribute("Activated")
	if attribute2 == false and debounce1 == false then
		debounce1 = true
		outside:SetAttribute("Activated", false)
		inside:SetAttribute("Activated", true)
		elevatormodule.move(elevator,area,elevatorgoals, left, right, doorgoalstable[3], doorgoalstable[1], shaft, back, doorgoalstable[4],doorgoalstable[2], front)
		debounce1 = false
	elseif attribute2 == true then return end
end)

outside.Touched:Connect(function()
	local attribute1 = outside:GetAttribute("Activated")
	local attribute2 = inside:GetAttribute("Activated")
	if attribute2 == true and not debounce2 then
		debounce2 = true
		inside:SetAttribute("Activated", false)
		outside:SetAttribute("Activated", true)
		task.spawn(elevatormodule.closeshaft,shaft,back)
		task.spawn(elevatormodule.closedoors,left, right,doorgoalstable[3],doorgoalstable[1])
		debounce2 = false
	elseif attribute1 == true then return end
end)

Picture of elevator and explorer tab:

3 Likes

Hey, can you provide a video of your issue to understand the synchronization better.

3 Likes

This is my output during testing:

Door used to close but not go first but now it doesn’t close at all:

2 Likes

The reason this is happening is because I’m touching the boxes named “inside” and “outside” with no cooldown. I don’t know how to prevent it.

2 Likes

Touching is only happening once now, but it isn’t synchronizing, I think it’s starting to work though.

2 Likes