I've got a script that I'm trying to make a part rotate around a pivot point, but whenever I try it, it errors;
22:13:13.060 - Workspace.TestModel.Script:15: bad argument #2 to '?' (Vector3 expected, got number) 22:13:13.061 - Script 'Workspace.TestModel.Script', Line 15 22:13:13.061 - Stack End
The code is
local pivot = CFrame.new() local part = game.Workspace.TestModel.Part local offset = part.CFrame:toObjectSpace(pivot):inverse() local initialRotation = part.CFrame - part.CFrame.p local firstTick = tick() local elapsed = 0 local speed = 16 -- deg/sec local desiredAngle = 30 local duration = desiredAngle/speed while elapsed <= duration do local alpha = math.min(1, elapsed/duration) local angle = desiredAngle*alpha part.CFrame = pivot*initialRotation*angle*offset elapsed = tick() - firstTick end
And I've tried this, but with the same result
local pivot = game.Workspace.TestModel.PivotPoint.CFrame local part = game.Workspace.TestModel.Part local offset = part.CFrame:toObjectSpace(pivot):inverse() local initialRotation = part.CFrame - part.CFrame.p local firstTick = tick() local elapsed = 0 local speed = 16 -- deg/sec local desiredAngle = 30 local duration = desiredAngle/speed while elapsed <= duration do local alpha = math.min(1, elapsed/duration) local angle = desiredAngle*alpha part.CFrame = pivot*initialRotation*angle*offset elapsed = tick() - firstTick end