Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[Solved]How do I fix my button spawning vertically instead of horizontally?

Asked by 5 years ago
Edited 5 years ago

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.

1 answer

Log in to vote
0
Answered by
chomboghai 2044 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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! :)

0
The first example you gave is what I am doing. The second example you gave is what I was doing. Could you help me see how changing the orientation will make the button lie flat? User#21908 42 — 5y
0
No wait your first example is close to what I am doing User#21908 42 — 5y
0
I am getting the xyz values from a vector3 value and I am puting the Value of the vector3 value inside of CFrame.new User#21908 42 — 5y
0
Do I need to put something in as the fourth parameter of CFrame? Or do I need to create a vector3, put the value inside of it, and then put that vector3 inside of CFrame? User#21908 42 — 5y
0
If your button's orientation is 0,0,0 but it's still standing vertically, then the sizing of your button part is the problem. If you want to make a 4x4 button lie flat, the size should be (4, 1, 4). The Y-Axis should be the short one. chomboghai 2044 — 5y
Ad

Answer this question