Untitled conversation
- Userlua
local offset local function rotationoffset(part) local size = part.Size local areas = { XY = size.X * size.Y, XZ = size.X * size.Z, YZ = size.Y * size.Z } local largest = 0 local pair = "" for i, v in areas do if v > largest then largest = v pair = i end end if pair == "XY" then offset = CFrame.Angles(math.rad(90), 0, 0) elseif pair == "XZ" then offset = CFrame.Angles(0, 0, math.rad(90)) else offset = CFrame.identity end end local part = workspace.Part if part then rotationoffset(part) part.CFrame = CFrame.new() * offset endWhy doesn't this script follow the instructions below:
make this code have an rotation offset variable at the top, and make it calculate the offset required so that i can do part.CFrame = CFrame.new(bla, bla, bla) * offset and it will have the biggest surface facing upwards. make sure that you do calculation that sets the rotation offset so that the largest surface is facing up. make sure to calculate all of that AFTER the part is fully found.
Are you able to fix it?
Here's some more info to possibly help you understand what I'm trying to say.
For example, if the size of the part was Vector3.new(4, 14, 3), the orientation would be set to 90, 0, 0 because that allows the biggest surface to be facing up, and it also makes sure that the longways would be set to where it could almost look like the player is walking a plank.
Here are some example outputs I would want:
Size: 4, 14, 3
Orientation: 90, 0, 0
Size: 15, 1, 5
Orientation: 0, 90, 0
Size: 3, 1, 14
Orientation: 0, 0, 0
As another example, for the size 1, 34, 7, I would want the output orientation to be 0, 90, 90.
The script should be able to find the orientation to position the part in the same way for all of these sizes:
1,34,7
1,7,34
34,1,7
34,7,1
7,1,34
7,34,1
- Assistant