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

Why can't I combine these CFrames?

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

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.

3 comments

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.

1

It looks like you didn't change the - between the CFrames into a *, which is what you said in your explanation

0

Yeah, ha ha! Sorry, I was tired! Fixed it now.

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