Skip to content

Instantly share code, notes, and snippets.

@ryanlua
Last active January 31, 2025 09:24
Show Gist options
  • Select an option

  • Save ryanlua/07ead666508636279999c6bd8af826cd to your computer and use it in GitHub Desktop.

Select an option

Save ryanlua/07ead666508636279999c6bd8af826cd to your computer and use it in GitHub Desktop.
local GuiService = game:GetService("GuiService")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local PlayerGui = Players.LocalPlayer.PlayerGui
local selectionImage = Instance.new("Frame")
selectionImage.Name = "SelectionImage"
selectionImage.BackgroundTransparency = 1
selectionImage.Size = UDim2.fromScale(1, 1)
local corner = Instance.new("UICorner")
corner.Name = "Corner"
corner.Parent = selectionImage
local stroke = Instance.new("UIStroke")
stroke.Name = "Stroke"
stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
stroke.Color = Color3.new(1, 1, 1)
stroke.Thickness = 3
stroke.Parent = selectionImage
local gradient = Instance.new("UIGradient")
gradient.Name = "GradientChild"
gradient.Color = ColorSequence.new({
ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 255, 255)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(86, 86, 86)),
})
gradient.Parent = stroke
local tween = TweenService:Create(
gradient,
TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, false, 0),
{ Rotation = 360 }
)
tween:Play()
GuiService:GetPropertyChangedSignal("SelectedObject"):Connect(function()
if GuiService.SelectedObject and GuiService.SelectedObject:FindFirstChildOfClass("UICorner") then
local parentCornerRadius = GuiService.SelectedObject:FindFirstChildOfClass("UICorner").CornerRadius
corner.CornerRadius = parentCornerRadius
else
corner.CornerRadius = UDim.new(0, 0)
end
end)
PlayerGui.SelectionImageObject = selectionImage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment