How to make a "copy to clipboard" button

So does anyone know how to make a copy to clip board button?

Ik how to:

script.parent:MouseButton1Up
1 Like

Unfortunately there is no API to copy things to a player’s clipboard. You’ll have to use a readonly TextBox for this instead.

3 Likes

oh, is there a way so that the user can just select the text?

You can focus a text box, and set it’s content (.Text) to be what you want the user to copy.

For security reasons, the user will have to copy the text themselves, which you could tell them to do with text like “Copy the text below”.

3 Likes

Maybe you should also tell them how to copy the text; You cannot right click and copy the text. Maybe tell them to select the text and press “ctrl + c”

It’s always a good idea to make sure the user knows how to perform the action (copy the text). It also might be a good idea to consider that on mobile there is no keyboard, and make the text display adapt to the platform.

local copy = “this is the text to copy”

script.parent.MouseButton1Click:Connect(function(plr)

setclipboard(tostring(copy))

end)

5 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.