I've done my reasearch, and I think it's time to ask the question. Let's say I have a part:
local Part=Instance.new("Part"),Part.Parent=workspace;Part,Orientation=Vector3.new(0,83,0)
The part has a orientation of 83 on the Y
axis. How then can
I move the part locally, like building models in Roblox Studio, where you can build models realitive to their orientation?
Cleaning up your code and fixing your syntactical errors, I have:
local Part = Instance.new("Part")
Part.Parent = workspace
Part.Orientation = Vector3.new(0, 83, 0)
If you want to place parts based on their position and orientation relative to this part, then you will want to use CFrames. Specifically, The ToWorldSpace
method. We can do as follows:
local function relativeToAbsolute(
relativeTo: CFrame, position: Vector3, orientation: Vector3
): (Vector3, Vector3)
local relative = CFrame.new(position) * CFrame.fromOrientation(
Vector3.new(math.rad(orientation.X), math.rad(orientation.Y), math.rad(orientation.Z))
)
local absolute = relativeTo:ToWorldSpace(relativeCFrame)
local rotX, rotY, rotZ = absolute:ToOrientation()
return absolute.Potision, Vector3.new(math.deg(rotX), math.deg(rotY), math.deg(rotZ))
end
Note that we have to convert to and from radians because the Orientation
property takes in degrees but everything else uses radians.
However, I think that it is better to just use CFrames directly instead of working with position and orientation, especially if you are trying to do more complicated things.