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

Aligning a part to the floor?

I am making a hoverboard and I need to have the part always rotating so it is aligned with the rotation of the ground. How would I do this?

2 comments

0

Please elaborate on this. At the moment I'm not sure what to visualize; could you maybe show a picture?

0

I think he means that the hoverboard should be parallel with the ground.

1 answer

So first you wanna find the rotation of the surface, let's call the part under the hoverboard "SurfacePart".

You would use this function to get the part rotation from its CFrame (The "x,y,z" values are the part position, while the other values are the rotation of the part)

local x,y,z,xx,yx,zx,xy,yy,zy,xz,yz,zz = SurfacePart.CFrame:components()

Then you would get the hoverboard CFrame (we will call it "newCFrame") by applying the rotation values to a new CFrame value.

newCFrame = CFrame.new(0,0,0,xx,-yx,-zx,xy,-yy,-zy,xz,-yz,-zz)

Of course you need to apply the board position, else the part will be placed at position (0,0,0). The board position would be called "Position" (Vector3 value)

newCFrame = CFrame.new(0,0,0,xx,-yx,-zx,xy,-yy,-zy,xz,-yz,-zz) + Position

You should read this to learn how CFrame works http://wiki.roblox.com/index.php?title=CFrame

1 comment

0

Of course you would rotate the newCFrame as you need.

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