Hello developers!
I was scripting an elevator door and then suddenly I come up with an issue.
When the door open tween are played, instead of it going to the actual position it goes to the last position the elevator was!
I tried switching Part0
and Part1
since I’m using WeldConstraints
and I got the same result.
Script
--- TweenService and TweenTimes ---
local TweenService = game:GetService("TweenService")
local TweenTime1 = TweenInfo.new(2)
local TweenTime2 = TweenInfo.new(12)
--- Objects ---
local Door1 = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("Door1",5)
local Door2 = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("Door2",5)
local Rope1 = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("Top",5).RopeConstraint1
local Rope2 = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("Top",5).RopeConstraint2
--- ClickDetector And Values ---
local Click = script.Parent:WaitForChild("ClickDetector" ,5)
local Moving = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("Moving",5).Value
local FloorValue = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("FloorValue",5).Value
if Door1 ~= nil and Door2 ~= nil and Click ~= nil then
Click.MouseClick:Connect(function(Player)
--- Close Tweens ---
local Door1CloseGoal = {}
Door1CloseGoal.Position = Vector3.new(Door1.Position.X, Door1.Position.Y, Door1.Position.Z - 1.5)
local Door1Close = TweenService:Create(Door1, TweenTime1, Door1CloseGoal)
--------------------------------------------------------------------------------------------------
local Door2CloseGoal = {}
Door2CloseGoal.Position = Vector3.new(Door2.Position.X, Door2.Position.Y, Door2.Position.Z + 1.5)
local Door2Close = TweenService:Create(Door2, TweenTime1, Door2CloseGoal)
--- Open Tweens ---
local Door1OpenGoal = {}
Door1OpenGoal.Position = Vector3.new(Door1.Position.X, Door1.Position.Y, Door1.Position.Z + 1.5)
local Door1Open = TweenService:Create(Door1, TweenTime1, Door1OpenGoal)
--------------------------------------------------------------------------------------------------
local Door2OpenGoal = {}
Door2OpenGoal.Position = Vector3.new(Door2.Position.X, Door2.Position.Y, Door2.Position.Z - 1.5)
local Door2Open = TweenService:Create(Door2, TweenTime1, Door2OpenGoal)
--------------------------------------------------------------------------------------------------
--- Rope Tweens ---
--- Up Tweens
local Rope1UpGoal = {}
Rope1UpGoal.Length = 1.1
local Rope1Up = TweenService:Create(Rope1, TweenTime2, Rope1UpGoal)
--------------------------------------------------------------------------------------------------
local Rope2UpGoal = {}
Rope2UpGoal.Length = 1.1
local Rope2Up = TweenService:Create(Rope2, TweenTime2, Rope2UpGoal)
--- Down Tweens ---
local Rope1DownGoal = {}
Rope1DownGoal.Length = 23.005
local Rope1Down = TweenService:Create(Rope1, TweenTime2, Rope1DownGoal)
--------------------------------------------------------------------------------------------------
local Rope2DownGoal = {}
Rope2DownGoal.Length = 23.005
local Rope2Down = TweenService:Create(Rope2, TweenTime2, Rope2DownGoal)
if Moving ~= true and FloorValue ~= 2 then
Moving = true
FloorValue = 0
workspace.Close:Play()
Door1Close:Play()
Door2Close:Play()
Door1Close.Completed:Connect(function()
wait(0.5)
Rope1Up:Play()
Rope2Up:Play()
Rope1Up.Completed:Connect(function()
wait(1)
Moving = false
FloorValue = 2
workspace.Open:Play()
Door1Open:Play()
Door2Open:Play()
end)
end)
end
end)
end
Thanks! Waiting for a reply.