Skip to content

Instantly share code, notes, and snippets.

@DuyNgao2306
Created May 19, 2026 00:10
Show Gist options
  • Select an option

  • Save DuyNgao2306/d38c6be5b78c570a808fbe145e00a1cf to your computer and use it in GitHub Desktop.

Select an option

Save DuyNgao2306/d38c6be5b78c570a808fbe145e00a1cf to your computer and use it in GitHub Desktop.
-- ================= SWITCH =================
local function createSwitch(text,order)
local frame = Instance.new("Frame", scroll)
frame.Size = UDim2.new(0.9,0,0,35)
frame.LayoutOrder = order
frame.BackgroundColor3 = Color3.fromRGB(210,210,210)
Instance.new("UICorner", frame)
local label = Instance.new("TextLabel", frame)
label.Size = UDim2.new(0.6,0,1,0)
label.Text = text
label.BackgroundTransparency = 1
label.TextScaled = true
local toggle = Instance.new("TextButton", frame)
toggle.Size = UDim2.new(0,45,0,22)
toggle.Position = UDim2.new(0.7,0,0.5,-11)
toggle.Text = ""
toggle.BackgroundColor3 = Color3.fromRGB(150,150,150)
Instance.new("UICorner", toggle)
local state = false
frame:SetAttribute("State",false)
toggle.MouseButton1Click:Connect(function()
state = not state
frame:SetAttribute("State",state)
toggle.BackgroundColor3 = state and Color3.fromRGB(0,200,100) or Color3.fromRGB(150,150,150)
end)
return frame
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment