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

Shaking a model rotation?

Asked by
lucas4114 607 Moderation Voter
8 years ago

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

0
Edited my answer. Perci1 4988 — 8y
0
Thank you! :D lucas4114 607 — 8y

1 answer

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
8 years ago

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
0
But I want it to rotate 10,0,0 up and down, not move up and down.. lucas4114 607 — 8y
Ad

Answer this question