Help: How to fix it?

local script in the button:

local uimodule = require(game.ReplicatedStorage.UiModule)
uimodule.Animate(script.Parent)

script.Parent.MouseButton1Down:Connect(function()
	uimodule.ToggleFrame(script.Parent.Parent.Frame)
end)

module script in replicatestorage:

local tweenService = game:GetService("TweenService")

local enterMulti = 1.1
local downMulti = 0.8

local hoverSound = script.hoverSound
local clickSound = script.clickSound

local AnimationModule = {}

local function enter(Button, size)
	tweenService:Create(Button, TweenInfo.new(.1), {Size = UDim2.new(size.X.Scale * enterMulti, size.X.Offset, size.Y.Scale * enterMulti, size.Y.Offset)}):Play()
	hoverSound:Play()
end
local function leave(Button, size)
	tweenService:Create(Button, TweenInfo.new(.1), {Size = size}):Play()
end
local function down(Button, size)
	tweenService:Create(Button, TweenInfo.new(.1), {Size = UDim2.new(size.X.Scale * downMulti, size.X.Offset, size.Y.Scale * downMulti, size.Y.Offset)}):Play()
end
local function up(Button, size)
	tweenService:Create(Button, TweenInfo.new(.1), {Size = UDim2.new(size.X.Scale * enterMulti, size.X.Offset, size.Y.Scale * enterMulti, size.Y.Offset)}):Play()
	clickSound:Play()
end

AnimationModule.Animate = function(Button)
	if Button:IsA("GuiButton") then
		local size = Button.Size
		
		Button.MouseEnter:Connect(function()
			enter(Button, size)
		end)
		Button.MouseLeave:Connect(function()
			leave(Button, size)
		end)
		Button.MouseButton1Down:Connect(function()
			down(Button, size)
		end)
		Button.MouseButton1Up:Connect(function()
			up(Button, size)
		end)
	end
end
AnimationModule.ToggleFrame = function(Frame)
	local position = Frame.Position
	if Frame:IsA("Frame") then
		if Frame.Visible == false then
			Frame.Position = UDim2.new(position.X.Scale, position.X.Offset, position.Y.Scale + 0.1, position.Y.Offset)
			Frame.Visible = true
			tweenService:Create(Frame, TweenInfo.new(.25, Enum.EasingStyle.Bounce), {Position = position}):Play()
		else
			Frame.Visible = false
		end	
	end
end

return AnimationModule

Problem:

It does not animate the button when mouseenter/mouseleave/mousebuttondown/mousebuttonup
Video:

Hey! I reviewed and tested your code and it looks normal, but I noticed that you didn’t change the default size of the button, so its size would probably be this, {0, 200},{0, 50}, but if you change it to something like, {0.1 , 0},{0.1, 0}, it works normally, I’m not sure why this happens, as I’m not a UI Designer, but it may solve the problem.

I’m going to test it now, I opening roblox studio

It works with size: {0.1 , 0},{0.1, 0} but not working with the size:{0.077, 0},{0.123, 0}
image

It’s working for me with that size, I suppose it might have something to do with your UI.

Idk why I give u solution but ty

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