Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

CFrame Expected, got number? Help?

local MainCFrame1 = script.Parent:GetPrimaryPartCFrame()

while game:GetService("RunService").Heartbeat:wait() do
    local sin, rad = math.sin, math.rad
    local t = tick()
    
local newCFrame1 = MainCFrame1 * CFrame.new(sin(t*1.8)*.5, (sin(t*1.6)*.5), (sin(t*2)*.5) * CFrame.Angles(rad(sin(t*3) * 2), rad(sin(t*3.2) * 4), rad(sin(t*3) * 6)))
    script.Parent:SetPrimaryPartCFrame(newCFrame1)

end

Output says

 bad argument #1 to '?' (CFrame expected, got number)

Any ideas on how to fix this?

1 answer

✓ Accepted answer

Your parenthesis are messed up, there should be another parenthesis at the end of the first CFrame. I fixed it and tested it for you. Here you go.

local MainCFrame1 = script.Parent:GetPrimaryPartCFrame()

while game:GetService("RunService").Heartbeat:wait() do
    local sin, rad = math.sin, math.rad
    local t = tick()

local newCFrame1 = MainCFrame1 * CFrame.new(sin(t*1.8)*.5, (sin(t*1.6)*.5), (sin(t*2)*.5)) * CFrame.Angles(rad(sin(t*3) * 2), rad(sin(t*3.2) * 4), rad(sin(t*3) * 6))
	script.Parent:SetPrimaryPartCFrame(newCFrame1)

end

let me know if there are any issues.

This discussion is preserved as it was. New answers, comments, and votes are closed.