Copy-to-Clipboard API

As a developer, it is impossible to automatically copy text to players’ clipboards.

If this issue is addressed, it would improve my development experience because I can provide GUIs that players can copy text from with single button click.

For example, one use would be to allow players to copy links to use in their web browser, such as asset pages, YouTube videos, or #bulletin-board posts.

Another example is in an “Inspect Player” screen, players could copy the player’s exact name to use elsewhere, such as to later paste into an admin console.

Inspect Player Mockup

As a side note, this should not allow for violating players’ privacy, as it only copies text to the clipboard. Not from it.

Also for safety reasons, this API should be disabled when the game window is not the active window.

55 Likes

I want an API for this too!

Lua Learning allows you to copy code blocks from tutorials by selecting + CtrlC, but a lot of the young users message me asking for a copy button because they don’t know keyboard shortcuts.

8 Likes

There is actually already a function for this, but its locked to core scripts. (it’s used in toolbox)

As an alternative to a click to copy button, replace the text label with a text box with TextEditable set to false. The player will then be able to copy the text, albeit with a few more steps (click, ctrl+a, ctrl+c).

If this were to be given to normal context scripts, there should probably be a length limit. (so you can’t copy gigabytes of text onto the clipboard)

4 Likes

This is Lua Learning’s method, more or less. Unfortunately, you’d be surprised how many people don’t know how to do that.

1 Like

Definitely something we need the ability to do! But somehow my gut tells me there’s a reason it hasn’t been approved.
(Abusing the clipboard system in a way that could let users put malicious urls in their clipboards and telling the user to CTRL + V into the search bar and pressing enter would definitely be bad)

6 Likes

It’s true. When I was at school, they had disabled the context menu in Windows Explorer, so people kept asking me how to copy and paste files.

@Beartikal maybe a confirmation dialogue when using the API; “Would you like to copy the following to your clipboard?”

9 Likes

It could be prone to spamming, and even with a rate limit, receiving a pop-up notification every 60 seconds or more would be really annoying.

Despite the pop-up notification, many children may simply click randomly to dismiss it and continue playing their games.

However, implementing this feature would be beneficial for plugins, the core script requirement would be lowered to plugin security,
a pop-up and something similar to Chrome’s pop-up security could be used so that plugins cannot prompt users without clicking on a button.

Edit: I didn’t realize this was 3 years ago lol but as far as I know it still isn’t implemented

If a game is misusing the API in a way that causes it to constantly pop up, then the game is poorly designed, not the API. Something very similar to this is how pop-ups for purchasing things ingame works: if the game abuses it and constantly tells you to buy something, you will get frustrated and leave. That’s the dev’s fault, not MarketplaceService’s fault.

A bad (or malicious) game dev can already do far worse than make a popup on your screen asking you to copy some text; that shouldn’t be a reason as to why this can’t be implemented.

6 Likes

I think if such an API was made available, it should be a one-time prompt per experience/plugin, or perhaps per-session for experiences.

However, I don’t believe there’s much benefit to experiences having access to the clipboard, but definitely would be useful to plugins, so I would be fine with a clipboard API being restricted to PluginSecurity.

1 Like

I thought it would be useful because of things like copying an instance into the clipboard or having a plugin that copies the full path of the currently selected instance for scripting. Maybe there could even be a ‘copy terrain’ plugin that allows you to easily copy terrain to a different game. The benefits I listed would save time, and the code is already there. They just need to lower the security level for plugins. I had the same idea of a simple permission when the plugin tries to access the clipboard API at first, but what the plugin is copying matters. If the plugin suddenly copies a phishing link instead of a Roblox link, for example, there wouldn’t be a pop-up and a developer may go to the link without noticing it changing. However, with plugins by verified creators being the default option in the toolbox and developers being more conscious than the average player, a simple permission system may still be useful.

1 Like

Sorry for replying late. I thought about it, and I guess it could also work for games.

Still require a strong need for this API. When testing huge swaths of data, there’s no real easy to copy all the strings contents outside of the roblox engine to read it in a text filer reader like notepad. This would be very very useful to be able to extract strings for reading.

I’m for it. If the browser has it (when the tab is active), why can’t Roblox?

The prompt should be for read access to the keyboard, not writing (as reading from the clipboard exposes sensitive data that may be copied to the clipboard, like a user’s password)