Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How Do I Make My Buttons On My Main Menu Enlarge When Someone Hovers Over Them With There Mouse ?

Here's My Current Code



--variables--
local playButton = script.Parent.PlayButton
local quitGameButton = script.Parent.QuitGameButton
local mainFrame = script.Parent

--scripts--
playButton.MouseButton1Click:Connect(function()
 mainFrame.Visible = false
end)

quitGameButton.MouseButton1Click:Connect(function()
 game.Players.LocalPlayer:Kick("You Left The Game")
end)

--Effects--
Gui.Object.MouseEnter:Connect(function()
	Gui.Object:TweenSize(0,511, 0,134)
	
	Gui.Object.MouseLeave:Connect (function()
		Gui.Object:TweenSize(0,489, 0,553)
		
		
	end)

1 answer

✓ Accepted answer

If you want the button to enlarge, then you should use either a for loop (not recommended) or GuiObject:TweenSize() . You should TweenSize since it's automatically built-in, and doesn't require TweenService. Also, it makes smooth transitions.

local playButton = script.Parent.PlayButton
local quitGameButton = script.Parent.QuitGameButton
local mainFrame = script.Parent

playButton.MouseEnter:Connect(function() --GuiObject means anything, like TextButton, TextLabels, or TextBoxes, etc.
	playButton:TweenSize(UDim2.new(0.2,0,0.2,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1, false) --UDim2 has 4 parameters. X Scale, X Offset, Y Scale, Y Offset. I'm only adding the scale. I'm also adding other stuff, which is the default TweenSize parameters anyways.
end)

playButton.MouseLeave:Connect(function() --Same thing as above.
	playButton:TweenSize(UDim2.new(0.15,0,0.15,0),Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1, false)
end)

playButton.MouseButton1Click:Connect(function()
	main.Frame.Visible = false
end)

quitGameButton.MouseEnter:Connect(function()
	quitGameButton:TweenSize(UDim2.new(0.2,0,0.2,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1, false)
end)

quitGameButton.MouseLeave:Connect(function()
	quitGameButton:TweenSize(UDim2.new(0.15,0,0.15,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1, false)
end)

quitGameButton.MouseButton1Click:Connect(function()
	game.Players.LocalPlayer:Kick("You Left The Game")
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.