-
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. -
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. -
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: