Hello! I am currently working on a game with a turntable that moves up and down. I’d like to make it so the turntable still spins while it is ascending/descending. The issue is however, the turntable stops spinning while it’s moving up. I’m unsure how to fix it.
So far, I’ve tried to tween the object to another part that is welded to the turntable so it follows the position of the part, but that didn’t work.
Tween Script:
local ti = TweenInfo.new(6,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)
ts:Create(game.workspace.TurnTables.TurntableModel.Turntable.TableModel.root,ti,{CFrame=game.workspace.P1.CFrame}):Play()
Turn Script:
local turnTables = {
workspace.TurnTables.TurntableModel,
workspace.TurnTables.TurntableModel2,
workspace.TurnTables.TurntableModel3,
}
local spinning = false
if not spinning then
spinning = true
game.workspace.TurnTables.TurntableModel.Turntable.Config.Speed.Value = 1 --speed of outer (make negative to change direction)
game.workspace.TurnTables.TurntableModel2.Turntable.Config.Speed.Value = 1 --speed of middle
game.workspace.TurnTables.TurntableModel3.Turntable.Config.Speed.Value = 1 -- speed of inner
spinning = false
end
local RunService = game:GetService("RunService")
local turnTables = {
workspace.TurnTables.TurntableModel,
workspace.TurnTables.TurntableModel2,
workspace.TurnTables.TurntableModel3,
}
local function startSpinning()
for _, turntableModel in ipairs(turnTables) do
local speed = turntableModel.Turntable.Config.Speed.Value
RunService.Heartbeat:Connect(function(deltaTime)
local currentCFrame = turntableModel.Turntable.TableModel.root.CFrame
turntableModel.Turntable.TableModel.root.CFrame = currentCFrame * CFrame.Angles(0, math.rad(speed * deltaTime), 0)
end)
end
end
startSpinning()
local ti = TweenInfo.new(6, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local targetPosition = game.workspace.P1.Position
local tween = ts:Create(game.workspace.TurnTables.TurntableModel.Turntable.TableModel.root, ti, {Position = targetPosition})
tween:Play()
You can repeatedly tween the object to make it spin when it is not moving up nor down, and then when you have to tween it up or down, have another tween to make it does both the spinning and moving.
The script could be something like this:
local function Spinning()
local goal = {CFrame = Part.CFrame * CFrame.Angles(math.rad(999),0,0)}
local tween = TweenService:Create(Part, TweenInfo.new(3), goal)
tween:Play()
task.wait(1)
Spinning() --Repeat the spinning tween
end
Spinning()
SomethingToTrigger:Connect(function()
local goal = {
Position = Vector3.new(-1.2, 19.56, -26.3);
CFrame = Part.CFrame * CFrame.Angles(math.rad(999),0,0)
}
local tween = TweenService:Create(Part, TweenInfo.new(3), goal)
tween:Play()
tween.Completed:Wait()
end)
Notes: Use Motor6D to connect between parts and the part you need to move.