so i’m facing this weird issue with TweenService
the problem is, i’m making a Open/Close Tween and when it comes to the “closing” part the part doesn’t really go 5 studs below it does 10 studs instead, not sure why its doing that.
function test()
local Tween = game:GetService("TweenService")
local TweenInfo = TweenInfo.new(5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0)
local Goal = {CFrame = script.Parent.CFrame + Vector3.new(0,5,0)}
local Goal2 = {CFrame = script.Parent.CFrame - Vector3.new(0,5,0)}
local TweenCreate = Tween:Create(script.Parent,TweenInfo,Goal)
local TweenCreate2 = Tween:Create(script.Parent,TweenInfo,Goal2)
TweenCreate:Play()
TweenCreate.Completed:Wait()
wait(1)
TweenCreate2:Play()
TweenCreate2.Completed:Wait()
test()
end
test()
The problem is occuring because the “Goal” variable is created before any movement is done, so the “closing” movement actually just moves the door from its normal state to below the ground.
Creating the second tween after the first one is fully complete will fix the issue.
function test()
local Tween = game:GetService("TweenService")
local TweenInfo = TweenInfo.new(5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0)
local Goal = {CFrame = script.Parent.CFrame + Vector3.new(0,5,0)}
local TweenCreate = Tween:Create(script.Parent,TweenInfo,Goal)
TweenCreate:Play()
TweenCreate.Completed:Wait()
wait(1)
local TweenCreate2 = Tween:Create(script.Parent,TweenInfo,Goal2)
local Goal2 = {CFrame = script.Parent.CFrame - Vector3.new(0,5,0)}
TweenCreate2:Play()
TweenCreate2.Completed:Wait()
test()
end
test()
yeah as i said i already know that but i didnt literally realise it.
i already know @Valkyrop 's tips but i just did this for fun not for an actual project or smth so yeah.