Hi, does anyone know how to make a text button, that copies some random text to your clipboard?
Currently not possible.
See more about the proposed API in this thread: Clipboard Access. It’s almost 7 and a half years old but still active and has a complete discussion on the pros and cons of implementing it.
Workaround?
Non-editable TextBox with a pre-selected text a user can copy and paste manually.
Standalone example (whereever local scripts work)
-- just a setup --
local screenGui = Instance.new("ScreenGui")
local textBox = Instance.new("TextBox")
textBox.ClearTextOnFocus = false
textBox.Size = UDim2.fromScale(.2,.1)
textBox.Position = UDim2.fromScale(.1,.1)
textBox.TextEditable = false
textBox.TextScaled = true
textBox.Parent = screenGui
screenGui.Parent = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")
------------------
textBox.Text = "Copy this with ease!"
textBox:CaptureFocus()
textBox.CursorPosition = string.len(textBox.Text) + 1
textBox.SelectionStart = 1
Thanks, but setclipboard works only if you use exploits
Yes, that is true, Synapse X had a similar method. However, I linked the thread to lead you to the discussion about adding such Roblox API and why it wasn’t implemented to-date. The proposed SetClipboard() is not associated with exploits.
There is a sample at the end of the reply? It shows the closest you can get to a copy button using TextBoxes, except the action has to be initiated by a user with ctrl+v or so.