How would I go about placing a thin layer of snow on top of an parts top face, I would just make the script clone the part at change the add to the Z value of the CFrame, but the parts are cframed and different sizes.
CFrames describe a position and orientation in space.
Actually, they describe the position and orientation relative to some reference frame.
If you have some reference
CFrame and some part
, then you can say
1 | relative = reference:toObjectSpace( part.CFrame ) |
to get a relative
CFrame which describes the offset from reference
to part.CFrame
.
To 'apply' this relative
change, you can use
1 | absolute = reference:toWorldSpace(relative) |
2 | -- or = reference * relative -- (same thing) |
For a Part, the origin (0, 0, 0) is the Part's CFrame. The Top surface is at CFrame.new(0, part.Size.y/2, 0)
.
Thus we can get a CFrame with the same orientation as Part, but at its Top surface, using
1 | top = part.CFrame * CFrame.new( 0 , part.Size.y/ 2 , 0 ) |
If you want to put a part on top of it that's 0.2 studs thick, then that part's center would have to be 0.1 studs further out:
1 | snow.Size = part.Size * Vector 3. new( 1 , 0 , 1 ) |
2 | snow.CFrame = part.CFrame * CFrame.new( 0 , part.Size.y/ 2 + 0.1 , 0 ) |