GUI not moving where I need

I am trying to make a button where when you hover over it, it moves. Although, when this happens, the gui moves into a position thats completly diffrent than where I wanted it to go. Heres my code: Any help?

local button = script.Parent
local frame = script.Parent.Parent
local buttonPos = UDim2.new({0.43, 0},{0, 0})


button.MouseEnter:Connect(function()
	frame.Position = UDim2.new({0.056, 0},{0.338, 0})
end)

Change the values in the function so that they match the desired location of your GUI. If you’re unsure, place the GUI where you think it should go and check the position.

try this

local button = script.Parent
local frame = script.Parent.Parent
local buttonPos = UDim2.new(0.43, 0,0, 0)

button.MouseEnter:Connect(function()
	frame.Position = UDim2.new(0.056, 0,0.338, 0)
end)

sometimes if you do not remove the {} from the position or it will not work

That is what I did but it goes in another position. For example I just want the frame to move slightly to the right side fo the screen but when I go into testing, it does go slightly right but it also goes up aswell. And I already used a plugin to make it visible at the same position for all screens (atleast thats what I think it does)

Thank you very much, I tried it and it worked.

1 Like

You need to remove the curly braces, Lua recognises them as table constructors, the UDim2.new() function expects number values not table values.

2 Likes