Need help with changing ui size

The UI doesn’t change their sizes when the mouse goes in and out any ideas?

local TweenService = game:GetService("TweenService")
local sound = script.Sound
local sound2 = script.Sound2
local ui = script.Parent

local originalSize = ui.Size
local enlargedSize = UDim2.new(originalSize.X.Scale * 1.1, originalSize.X.Offset, originalSize.Y.Scale * 1.1, originalSize.Y.Offset)

local function resizeButton(button, targetSize)
	local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
	local tween = TweenService:Create(button, tweenInfo, {Size = targetSize})
	tween:Play()
end

local function shrinkButton(button)
	resizeButton(button, originalSize)
end

ui.MouseEnter:Connect(function()
	resizeButton(ui, enlargedSize)
	sound:Play()
end)

ui.MouseLeave:Connect(function()
	shrinkButton(ui)
end)

ui.MouseButton1Click:Connect(function()
	sound2:Play()
end)

here’s what it looks like in the explorer

image

here’s a video of me testing the ui:

change this UDim2.new(originalSize.X.Scale * 1.1, originalSize.X.Offset, originalSize.Y.Scale * 1.1, originalSize.Y.Offset)
for this
UDim2.new(originalSize.X.Scale + 1.1, originalSize.X.Offset, originalSize.Y.Scale + 1.1, originalSize.Y.Offset)

by the way I recommend using es:

ui:TweenSize()

instead of getting the interpolation service
edit: is not referencing the button, it is referencing the Screen Gui

local ui1 = script.Parent.Buttons.Food
local ui2 =  script.Parent.Buttons.Inventions
local ui2 =  script.Parent.Buttons["???"]
--now change one by one

you must also reference and change one by one

ultime edit: the solution is probably that you should use TweenSize

Are you receiving any errors in the output?
Try adding print statements under both MouseEnter and MouseLeave functions to determine if those functions even run.

your script works, it just has a calculation problem I think, you should scale the button in edit mode, copy the size, and paste it in the variable enlargedSize and it would be easy.

Although TweenSize (and its related functions) are simpler to use, TweenService is more complex and has much more use for a variety of things. But it generally shouldn’t matter which method you use. None of which should have a problem (unless you use it the wrong way). I’d personally recommend using TweenService if you nearly have a full understanding of it.

I did not find any errors in the output

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.