Button Press Animation with UIScale thumbnail
0 views0 copies0 likes

Button Press Animation with UIScale

Universal script

Copy it, then test it in your own Studio place.

UI systems Verified

Script code

21 lines · 0.8 KB
Download
local TweenService = game:GetService("TweenService")local button = script.Parentlocal scale = button:FindFirstChildOfClass("UIScale") or Instance.new("UIScale", button)local size = scale.Scalelocal tween, clickId = nil, 0local function resize(goal, seconds)	if tween then tween:Cancel() end	tween = TweenService:Create(scale, TweenInfo.new(seconds, Enum.EasingStyle.Quad), {Scale = goal})	tween:Play()endbutton.MouseButton1Down:Connect(function() resize(size * 0.92, 0.06) end)button.MouseButton1Up:Connect(function() resize(size, 0.14) end)button.SelectionLost:Connect(function() resize(size, 0.14) end)button.Activated:Connect(function()-- …open Get script for the full source

About this script

Add this LocalScript inside an ImageButton or TextButton. It inserts a UIScale if needed, shrinks the button when pressed, and returns it to its original scale with a short easing tween. Rapid changes cancel the previous tween, and tapping also triggers a short press. Attach your gameplay handler separately and test the animation with keyboard, mouse and touch.

Comments

Share what works, ask questions, or report an issue.

0

Log in to leave a comment.

No comments yet

Be the first to share your thoughts!

Raw Luau source

local TweenService = game:GetService("TweenService")
local button = script.Parent
local scale = button:FindFirstChildOfClass("UIScale") or Instance.new("UIScale", button)
local size = scale.Scale
local tween, clickId = nil, 0
local function resize(goal, seconds)
	if tween then tween:Cancel() end
	tween = TweenService:Create(scale, TweenInfo.new(seconds, Enum.EasingStyle.Quad), {Scale = goal})
	tween:Play()
end
button.MouseButton1Down:Connect(function() resize(size * 0.92, 0.06) end)
button.MouseButton1Up:Connect(function() resize(size, 0.14) end)
button.SelectionLost:Connect(function() resize(size, 0.14) end)
button.Activated:Connect(function()
	clickId += 1
	local stamp = clickId
	resize(size * 0.92, 0.06)
	task.delay(0.07, function()
		if stamp == clickId and button.Parent then resize(size, 0.14) end
	end)
end)