local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local screenGui = Instance.new("ScreenGui")
local textButton = Instance.new("TextButton")
local gradient = Instance.new("UIGradient")
local corner = Instance.new("UICorner")
--// (mistake from me) DO NOT RELEASE THIS. Instance.new("Script")
screenGui.Name = "DraggableButtonUI"
screenGui.Parent = playerGui
screenGui.ResetOnSpawn = false
textButton.Name = "RoundedButton"
textButton.Parent = screenGui
textButton.Size = UDim2.new(0, 300, 0, 100)
textButton.Position = UDim2.new(0.5, 0, 0.5, 0)
textButton.AnchorPoint = Vector2.new(0.5, 0.5)
textButton.Text = "Hover Me!"
textButton.TextSize = 18
textButton.Font = Enum.Font.SourceSansBold
textButton.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
textButton.TextColor3 = Color3.fromRGB(255, 255, 255)
textButton.BorderSizePixel = 0
corner.CornerRadius = UDim.new(0.1, 0)
corner.Parent = textButton
gradient.Color = ColorSequence.new{
ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 51, 51)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(144,213,255))
}
gradient.Parent = textButton
local ts = game:GetService("TweenService")
local hoverInTween = ts:Create(
textButton,
TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.In),
{BackgroundTransparency = 0.2}
)
local hoverOutTween = ts:Create(
textButton,
TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
{BackgroundTransparency = 0}
)
local pressTween = ts:Create(
textButton,
TweenInfo.new(0.2, Enum.EasingStyle.Back, Enum.EasingDirection.Out),
{Size = UDim2.new(0.5, 0, 0.15, 0)}
)
local releaseTween = ts:Create(
textButton,
TweenInfo.new(0.2, Enum.EasingStyle.Back, Enum.EasingDirection.In),
{Size = UDim2.new(0, 300, 0, 100)}
)
local ti = TweenInfo.new(2.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true)
local offsetEnd = {Offset = Vector2.new(1, 0)}
local gradientTween = ts:Create(gradient, ti, offsetEnd)
gradientTween:Play()
textButton.MouseEnter:Connect(function()
hoverInTween:Play()
end)
textButton.MouseLeave:Connect(function()
hoverOutTween:Play()
end)
textButton.MouseButton1Down:Connect(function()
pressTween:Play()
end)
textButton.MouseButton1Up:Connect(function()
releaseTween:Play()
end)
local dragging = true
local dragInput
local dragStart
local startPos
textButton.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButtonClick1 then
dragging = true
dragStart = input.Position
startPos = textButton.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragging = false
end
end)
end
end)
game:GetService("UserInputService").InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement and dragging then
local delta = input.Position - dragStart
textButton.Position = UDim2.new(
startPos.X.Scale,
startPos.X.Offset + delta.X,
startPos.Y.Scale,
startPos.Y.Offset + delta.Y
)
end
end)
Comments
https://pastebin.com/raw/w9xQW3ey here u go enjoy
check ur discord