Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"bad argument #2 to '?' (Vector3 expected, got number)" error, don't know how to fix it?

Asked by 8 years ago

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
0
oof, three years and still no answer. sorry bud, you might have to try re-uploading. i am looking for the answer myself. LuckyOnes187 39 — 4y

Answer this question