How can I make the Gui centered while its size is tweening?

I made a script that makes the UI bigger when you hover your mouse on it, but it doesn’t center the ui scale when i hover.
example:
robloxapp-20220818-0920436.wmv (622.7 KB)

local guiObject = script.Parent


guiObject.MouseEnter:Connect(function()
	print("Join")
	guiObject:TweenSize(UDim2.new(0.067,0,0.119,0), "InOut", "Quint", .1, true)
end)
guiObject.MouseLeave:Connect(function()
	print("Left")
	guiObject:TweenSize(UDim2.new(0.059, 0,0.105, 0), "InOut", "Quint", .1, true)
end)

pls someone make it somehow centered and clean

Could you send me a model of the game? I think that this problem has to do with the position of the gui’s…

Here Settings - Roblox

Thanks, I will now look into this problem and come back with a solution soon…

1 Like

Try this code:

local Players = game:GetService("Players")
local LPlayer = Players.LocalPlayer
local PlayerGUI = LPlayer:WaitForChild("PlayerGui")
local gui = PlayerGUI:WaitForChild("Settings")
local button = gui:WaitForChild("ImageButton")

button.MouseEnter:Connect(function()
print("Join")
button:TweenSize(UDim2.new(0.067,0,0.119,0), "InOut", "Quint", .1, true)
button:TweenPosition(UDim2.new(0.021, 0,0.264, 0),"InOut", "Quint", .1, true)
end)

button.MouseLeave:Connect(function()
print("Left")
button:TweenSize(UDim2.new(0.059, 0,0.105, 0), "InOut", "Quint", .1, true)
button:TweenPosition(UDim2.new(0.021, 0,0.264, 0),"InOut", "Quint", .1, true)
end)

Make sure to set the anchorpoint of the UI_Object that you’re tweening to 0.5,0.5

2 Likes