In my tycoon I have a script which creates buttons for all the unowned items. The script clones a button model from ServerStorage and sets all of the stringvalues, intvalues, and so on, to be the values inside of the item that needs a button. Recently I asked a question about how to set the position of an object and someone said to use CFrames. So I went through and changed all of my scripts to assign position via CFrame. When I went into the game though, I quickly realized the my buttons were appearing like this: | and not like this: _ . I will note that the buttons were sticking out of the ground halfway. Is there any way to fix this and still use CFrames or should I just go back to Position for this particular instance? Thanks!
Note: If you need any additional information please ask for it in the comments below.
A CFrame is a data structure that holds position as well as the orientation. If you don't want the button's to have a particular orientation, then simply set the position of it, or create a new CFrame with the specified position and no orientation. Most likely you are creating a CFrame with non-zero values for the rotation matrix.
local button -- reference to button local targetPosition = Vector3.new(targetX, targetY, targetZ) -- creates a new CFrame with specified position and no orientation -- NOTE!: I am using a Vector3 as the input, not 3 different values for the X Y Z. local buttonCFrame = CFrame.new(targetPosition) -- but you could use the three values local buttonCFrame = CFrame.new(targetX, targetY, targetZ) button.CFrame = buttonCFrame -- this will set the position and set orientation to 0 -- OR YOU CAN DO button.Position = targetPosition -- this will set the position and keep current orientation
Basically you can set the position whichever way you want, it shouldn't change much.
Hope this helps! :)