I'm trying to make a model's rotation shake, by 10,0,0 up then back down, and I tryed this:
while wait(2) do script.Parent:SetPrimaryPartCFrame(CFrame.new(0,0,0 * 10,0,0)) wait(2) script.Parent:SetPrimaryPartCFrame(CFrame.new(0,0,0 * -10,0,0)) end
It doesn't work and the output says this: 10:57:29.167 - Invalid number of arguments: 5
The output tells you the exact problem. You have too many arguments.
You're thinking about it a bit wrong. The first three numbers will not be multiplied by the second three. Take a look at it rearranged a bit;
script.Parent:SetPrimaryPartCFrame(CFrame.new(0, 0, (0*10), 0, 0))
See what's happening? 0*10
is treated as a completely separate argument, as is all the zeros. It will not multiply the first three numbers by the second three numbers. It will multiply 0*10
, treating as just another argument that happens to have some multiplication.
So you mean to rotate it. For this, we'll just use CFrame.Angles to change the rotation. We'll multiply CFrame.Angles by the part's current CFrame, so it will stay in the same position.
local part = script.Parent.PrimaryPart script.Parent:SetPrimaryPartCFrame(part.CFrame * CFrame.Angles(10, 0, 0)) -- -10 for opposite direction
Or if you want it in degrees, which I think are easier;
local part = script.Parent.PrimaryPart script.Parent:SetPrimaryPartCFrame(part.CFrame * CFrame.Angles(math.rad(10), 0, 0)) -- -10 for opposite direction