Buttons are going to corner of the screen after changing their position

Im trying to change the position of the buttons to the original position but when i run the function the buttons go to the top corner of the screen

b1080752d623e20050f5823b7b744f1f

Code:

local Screen = script.Parent.ScreenGui

local buttonPos = {
	------ Original ------
	-- credits
	{0.334, 0},{0.54, 0},
	-- shop
	{0.334, 0},{0.422, 0},
	-- servers
	{0.334, 0},{0.302, 0},
	------ Next ------
	-- credits
	{0.013, 0},{0.569, 0},
	-- shop
	{0.013, 0},{0.45, 0},
	-- servers
	{0.013, 0},{0.33, 0}
}

function buttonvis (pos)
	if pos == "original" then
		Screen.Servers.Position = UDim2.new(buttonPos[3])
		Screen.Credits.Position = UDim2.new(buttonPos[1])
		Screen.Shop.Position = UDim2.new(buttonPos[2])
	elseif pos == "side" then
		Screen.Servers.Position = UDim2.new(buttonPos[6])
		Screen.Credits.Position = UDim2.new(buttonPos[4])
		Screen.Shop.Position = UDim2.new(buttonPos[5])
	end
end

buttonvis("original")

Does changing the Position change the Origin of the GUIs?
I think the default Origin is top left. Have a look at the GUI Properties before and after the change to see what else other than the Position has changed.

i dont believe it should be going back to the origin, i just named it origin as short for original. and the only thing changing is the position going to {0,0},{0,0}

idk if bumping works but bump -------------------

But that’s what I mean.
Look at the Origin value from before you move it, and check it while you are testing it to see what value changes.

You are using UDim2.new() strangely here. The table does not even store all the UDim2 values per position in one entry which I don’t think is what you intended. You could store all the UDim2 values in one entry using a table with 4 values and unpacking that into UDim2.new(), but really, the easiest fix here is just to create the UDim2s in the table itself:

local buttonPos = {
	-- Credits
	UDim2.new(0.334, 0, 0.54, 0),
	-- Shop
	UDim2.new(0.334, 0, 0.442, 0),
	-- Add more below here
}

Then just set the values directly to the position. As an example:

Screen.Servers.Position = buttonPos[3]
1 Like