Here you go, this is the tweening code:
function tweens.TweenCube(direction)
if not inMotion then
inMotion = true
if direction == "UP" then
if isHorizontal then
else
local tweenInfo = TweenInfo.new(
0.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local tweenProperties = {
CFrame = CFrame.new(Vector3.new(mainPart.Position.X + 4, mainPart.Position.Y, mainPart.Position.Z)) * CFrame.Angles(math.rad(mainPart.Orientation.X), math.rad(mainPart.Orientation.Y), math.rad(mainPart.Orientation.Z) - math.rad(90)),
}
local cubeTween = TweenService:Create(mainPart, tweenInfo, tweenProperties)
cubeTween:Play()
cubeTween.Completed:Wait()
mainPart.Orientation = Vector3.new(0, 0, 0)
end
elseif direction == "DOWN" then
if isHorizontal then
else
local tweenInfo = TweenInfo.new(
0.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local tweenProperties = {
CFrame = CFrame.new(Vector3.new(mainPart.Position.X - 4, mainPart.Position.Y, mainPart.Position.Z)) * CFrame.Angles(math.rad(mainPart.Orientation.X), math.rad(mainPart.Orientation.Y), math.rad(mainPart.Orientation.Z) + math.rad(90)),
}
local cubeTween = TweenService:Create(mainPart, tweenInfo, tweenProperties)
cubeTween:Play()
cubeTween.Completed:Wait()
mainPart.Orientation = Vector3.new(0, 0, 0)
end
elseif direction == "RIGHT" then
if isHorizontal then
else
local tweenInfo = TweenInfo.new(
0.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local tweenProperties = {
CFrame = CFrame.new(Vector3.new(mainPart.Position.X, mainPart.Position.Y, mainPart.Position.Z + 4)) * CFrame.Angles(math.rad(mainPart.Orientation.X) + math.rad(90), math.rad(mainPart.Orientation.Y), math.rad(mainPart.Orientation.Z)),
}
local cubeTween = TweenService:Create(mainPart, tweenInfo, tweenProperties)
cubeTween:Play()
cubeTween.Completed:Wait()
mainPart.Orientation = Vector3.new(0, 0, 0)
end
elseif direction == "LEFT" then
if isHorizontal then
else
if isHorizontal then
else
local tweenInfo = TweenInfo.new(
0.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local tweenProperties = {
CFrame = CFrame.new(Vector3.new(mainPart.Position.X, mainPart.Position.Y, mainPart.Position.Z - 4)) * CFrame.Angles(math.rad(mainPart.Orientation.X) - math.rad(90), math.rad(mainPart.Orientation.Y), math.rad(mainPart.Orientation.Z)),
}
local cubeTween = TweenService:Create(mainPart, tweenInfo, tweenProperties)
cubeTween:Play()
cubeTween.Completed:Wait()
mainPart.Orientation = Vector3.new(0, 0, 0)
end
end
end
inMotion = false
end
end