My model has 2 scripts
local PIVOT_FRAME = script.Parent.PivotCFrame
local Model = script.Parent
PIVOT_FRAME.Value = Model:GetPivot() -- puts it back to it's place
PIVOT_FRAME.Changed:Connect(function(val)
Model:PivotTo(val)
end)
What is does: It makes your model be able to be tweened, since you can’t tween a PVInstance, I made the pivot move to the CFrameValue’s value whenever it changes.
The 2nd script which tweens the model
local TweenService = game:GetService('TweenService')
local PivotValue = script.Parent.PivotCFrame
local TweenLeft = TweenService:Create(
PivotValue,
TweenInfo.new(
0.7,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0
),
{
Value = CFrame.fromOrientation(0,0,math.rad(7))
}
)
local TweenRight = TweenService:Create(
PivotValue,
TweenInfo.new(
0.7,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0
),
{
Value = CFrame.fromOrientation(0,0,math.rad(-7))
}
)
coroutine.wrap(function()
while true do
TweenLeft:Play()
TweenLeft.Completed:Wait()
TweenRight:Play()
TweenRight.Completed:Wait()
end
end)()
But when I test it, it just moves the pivot CFrame to 0,0,0 instead, it does tween the rotation though. I tried EVERYTHING, and still can’t get it to work. Can someone tell me what’s wrong with this?