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

Why can't I combine these CFrames?

Asked by
ZeroBits 142
9 years ago

when I try to run this code;

game.Workspace.bigSector.PrimaryPart.CFrame = CFrame.new(game.Workspace.bigSector.Center.Position) - CFrame.Angles(0,math.rad(game.Workspace.playerShipMini.smallShip.Rotation.Y),0)

it gives me this error;

15:41:02.341 - Workspace.Script:15: bad argument #2 to '?' (Vector3 expected, got userdata) 15:41:02.346 - Script 'Workspace.Script', Line 15 - global move

what can I do to make this return an actual CFrame?

1 answer

Log in to vote
2
Answered by 9 years ago

You have to multiply the CFrame when using CFrame.Angles as addition and subtraction of CFrames are reserved for Vector3 values. To make it so it subtracts the angle instead of adding onto it, you have to add a '-' (without quotes) before math.rad, like this:

game.Workspace.bigSector.PrimaryPart.CFrame = CFrame.new(game.Workspace.bigSector.Center.Position) * CFrame.Angles(0,-math.rad(game.Workspace.playerShipMini.smallShip.Rotation.Y),0)

I hope this answer helped you. If it did, be sure to accept it.

0
Sadly, it doesn't really help in my case, I'll still give you an upvote though, as it was a really good answer to the wrong problem. ZeroBits 142 — 9y
1
It looks like you didn't change the `-` between the CFrames into a `*`, which is what you said in your explanation BlueTaslem 18071 — 9y
0
Yeah, ha ha! Sorry, I was tired! Fixed it now. Spongocardo 1991 — 9y
Ad

Answer this question