-- Script Below




















































local frame = script.Parent
local rgb = Color3.fromRGB
local ud2 = UDim2.new
repeat
	wait()
until game.Players.LocalPlayer
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

frame.ClipsDescendants = true
frame.AutoButtonColor = false


function tweenInRipple(ripple)
	spawn(function()
		local TweenService = game:GetService("TweenService")
		local Part = ripple
		local Info = TweenInfo.new(
			TimeLength,
			Enum.EasingStyle.Linear,
			Enum.EasingDirection.InOut,
			0,
			false,
			0
		)
		local Goals = 
		{
			Size = ud2(0, PixelSize, 0, PixelSize);
		}
		local Tween = TweenService:Create(Part, Info, Goals)
		Tween:Play()
	end)
end

function fadeOutRipple(ripple)
	spawn(function()
		local TweenService = game:GetService("TweenService")
		local Part = ripple
		local Info = TweenInfo.new(
			FadeLength,
			Enum.EasingStyle.Linear,
			Enum.EasingDirection.InOut,
			0,
			false,
			0
		)
		local Goals = 
		{
			ImageTransparency = 1;
		}
		local Tween = TweenService:Create(Part, Info, Goals)
		Tween:Play()
		wait(FadeLength + 0.1)
		ripple:Destroy()
	end)
end

frame.MouseButton1Down:Connect(function()
	local done = false
	local ripple = script.Circle:Clone()
	ripple.Parent = frame
	ripple.ZIndex = frame.ZIndex + 1
	ripple.ImageColor3 = RippleColor
	ripple.ImageTransparency = RippleTransparency
	tweenInRipple(ripple)
	frame.MouseButton1Up:Connect(function()
		if done == false then
			done = true
			fadeOutRipple(ripple)
		end
	end)
	wait(4);
	done = true;
	fadeOutRipple(ripple) -- if it doesnt detect that it was unselected
end)
