How to create a button that copies text to the Clipboard, in a plugin

I want to know how it is possible to make it so that when you click on a button it will copy certain text to the clipboard, the button is in the plugin.

I’m not sure it’s possible to directly copy text to clipboard. The closest workaround I know of is to select the contents of a TextBox so the user can use Ctrl+C to copy to clipboard themselves.

local selectTextButton: TextButton --Button that selects the text
local textBox: TextBox --Stores the text you want the user to copy

selectTextButton.Activated:Connect(function()
   textBox.SelectionStart = 1
   textBox.CursorPosition = string.len(textBox.Text) + 1
end)

Make sure ClearTextOnFocus is false on the TextBox. You could additionally set TextEditable to be false to prevent accidently changes by the user when selecting the text.