Clipboard Access

Still no idea what AddToClipboard is.
If I do SetClipboard("abc") AddToClipboard("idk") what will be the result?

I’m for it. I think the security issues associated with it might be a little exaggerated. However, if we limit it to callbacks which are invoked when the user presses ctrl+v or ctrl+c, it would be safer. Then, the user would have to be actively pasting his password into ROBLOX, at which point I think any leaked password info is his/her own fault.

This would lead to an API such as the following:

local ClipboardService = game:GetService("ClipboardService");
ClipboardService.OnCopy = function(cut)
    --cut is true if ctrl+x was pressed, and false if ctrl+c was pressed.
    return "text";
    --value can be text, or if the value was cut from ROBLOX studio, it may be an instance.

I too don’t totally understand why we’d have AddToClipboard. It would be confusing for the user, because pretty much no software adds stuff to a clipboard.


Adding is intended for when I have a list of ROBLOX objects copied to my clipboard and I want to add another object to that list.
If you were sure the user had ROBLOX objects copied to their clipboard, you probably put them there in the first place and already know what they are. AddToClipboard would be pointless in this case. Removed from OP.

That’s the essence of ClipboardPasted that I had in the OP, but I’m not sure whether or not it’d be worth it for Ctrl+C. I could set a keybind in my game to Ctrl+C and then I have free reign to the user’s clipboard – it doesn’t stop the people who’d abuse it.

Setting the clipboard should be initiated by the user. The user should know what he’s getting.

  1. Implement a textbox that doesn’t suck.
  2. When focused, a user can press [shortcut] to copy highlighted text.

I’m torn between this being useful and it being a security risk. People have already addressed the idea of people just having their clipboard set to whatever, but that’s an inherent risk regardless. I’m not inherently against a notification telling people their clipboard has been changed, but it’d get annoying.

Maybe have two different methods? Have one that sets the clipboard only for that particular instance in ROBLOX (that’d be on ROBLOX’s part, though), and have one that requires user confirmation to set the clipboard in its actuality? Hell, even make the user confirmation cache per session so you don’t have to be asked more than once. Would mitigate the aforementioned issue with people just having their clipboard set by any old place.

As for getting the clipboard? Yeah, it’s not reasonable to just get the clipboard, unless it was confirmed by the user, again. A clipboard pasted event would work for most cases, but there’s always the edge cases. Perhaps just allow the developer to get the clipboard contents if its been set by ROBLOX (dunno how’d you keep track of that, it might have to be in the same session) and ask for confirmation on the user’s part otherwise.

This is a unique issue because it affects people outside of the game. A game spams audio? You leave the game. A plugin destroys your place? You uninstall it and reload the place. You accidentally paste your password into some guy’s plugin? …Well you’re SOL.

That’s just my opinion though. Could be entirely unreasonable.

Not useful. Textboxes that don’t suck are great, but it doesn’t provide as much functionality:

  • I can’t copy text from TextLabels/(Buttons?) like how I can by highlighting your text on Discourse to quote you
  • As a plugin developer I can’t use the clipboard for ROBLOX objects. The whole point of having access to the clipboard is so that I don’t have to do Selection:Set() on some weird objects I hide in Geometry and can just add them to the clipboard directly

I don’t understand the big deal with “security”. Someone setting your clipboard to something dumb affects you so little. You have to paste without copying something first to even see what the ROBLOX client/studio set your clipboard to, and that’s most likely not going to happen. The only “security issue” here is an invented one that’s being over-embellished.


I mean any text UI. Obviously the whole thing sucks.

I’m down with explicitly setting just objects to the clipboard. I can’t think of any cases for explicitly setting text (assuming that text UI doesn’t suck).

It’s insecure for the same reason that email attachments are insecure. It affects you in particular very little, because you’re careful and knowledgeable. A lot of people aren’t, though. Another point is that Roblox runs user-generated code on a player’s machine, and they have an interest in keeping the player safe. They aren’t just going to expose operating system functions willy-nilly, even if they’re seemingly harmless.

1 Like

Quick copying. Take this site for example. You can click on the text faces once to copy the whole thing to your clipboard as opposed to manually select the whole thing character by character.

This is not why. It affects everyone little by design. If you want to paste something from your clipboard, you want to paste what you copied earlier. In other words, if anyone pastes something, they’ve already copied something else, even if they weren’t careful/knowledgeable, that overwrites what it’s been set to in ROBLOX.

Nothing’s being exposed, just as the ROBLOX API doesn’t expose the internal C++ code. The API is a controlled interface, and that’s it. I don’t see how this is any different that setting the vibration of a controller for instance – we’re using (controlled) interfaces to manipulate system functions (in a controlled manner) in both cases.

Assuming the text UI didn’t suck, it would have an API for setting the highlighted text, which would let you highlight all the text on-click, or on-focus, or whatever. Most websites already do this, since the JS clipboard API is only a recent addition. The reason it’s recent is because of -you guessed it- security (here’s a neat explanation).

People want to paste what they explicitly copied, not what was automatically set as a side-effect of some other action. By design, every program that copies to the clipboard makes sure the user understands the contents of the clipboard, and that the user initiated the action.

When a programmer wants to expose the clipboard through some API, if they want to ensure that this design is maintained, then they must implement it in particular way. Otherwise, users of that API could use it in a way that goes against the design, affecting the UX of the program.

The clipboard, a component of the OS, is what’s being exposed. At the very end, Roblox would be allowing user-generated data enter the clipboard. So what kind of data is allowed, and how that data gets there, must be considered carefully.

The reason I’m okay with copying instances directly is because it’s effectively impossible to accidentally paste that data into an unintended location, like a URL bar.


If it had text selection, this, and allowed free domain over ROBLOX objects with the clipboard, then that would be enough. Unless someone has anything else to add, that covers all of the use cases I have.

I created Lua Learning, and as I’m typing this, it’s on the Front Page. :grin:

My feedback web-hook, my Roblox messages, and my Discord DMs are all being filled with players asking me to let them copy code examples from the game into Studio. This is a feature that is being requested by many.

As far as I can find, there isn’t a way to do this. Within the game, they can copy paste, but that’s a simple custom clipboard that exists only within the game. I don’t have a method to put it in the user’s actual clipboard.

Has this changed? Will it ever? It’s a really crucial feature for some.

1 Like

I’m currently working to ship a feature that lets you select and copy paste in textboxes on PC. Note that copying from a textbox is already possible on mobile, though it’s clunky when the expectation is being able to tap a button. On desktop, the new functionality requires users to explicitly press ctrl+C, but you will be able to do most of the work for them by doing:

textbox.CursorPosition = string.len(textbox.Text)
textbox.SelectionStart = 1

which will pre-select the text, and all they have to do is press ctrl+C. In the future we can consider adding a feature for this that works without prompting the user, if this isn’t good enough.


@Tiffblocks Allowing plugins to write to the clipboard would be useful for a plugin I am creating. It would allow the user to easily copy the ID of a mesh/image/sound to their clipboard



I would benefit from using this feature. I would use it to allow users to copy a deeplink to their clipboard.

do you not realise??? you can??? already make key loggers???

1 Like

I would love clipboard functionality tbh.

Though even if you restrict it to only in-game copy/pasting, it’s still abusable.
Malicious devs can paste site links into someone’s clipboard.

HOWEVER, one solution to this would be to have the experience ASK the user for permission like plugins do.

A experience can only ask a user for clipboard permission ONCE, if the user clicks “decline” it returns false in script.

Additionally, there could be security options.
Let’s say we have a clipboard service.

local cs = game:GetService("ClipboardService")

local perms = cs:RequestPermission() -- Prompts player with a GUI much like in-game purchases.

if perms == Enum.PermissionLevel.None then
 print("User didn't give permission, clipboard functionality disabled.")

elseif perms == Enum.PermissionLevel.Restricted then
 print("User gave in-game-only clipboard permission.")

elseif perms == Enum.PermissionLevel.Full then
 print("User gave full clipboard permission.")

What are the differences between all the modes?

None doesn’t allow any clipboard access.
Both copying and pasting is disabled and will error in script if attempted.

Restricted only allows the game to get text from the clipboard that was also obtained/copied in-game.
This avoids malicious devs from copying potential personal information or passwords someone used to log into a site.

The Full permission gives full clipboard permission.
This let’s the game also read clipboard content from outside the game.

Useful if you want to allow players to save and load their game data locally by letting them save a .txt file to their clipboard.

If you want to load a file from a player’s computer into the game, they can copy the file’s contents (such as local game save and settings data or a midi file for playing musical notes) and ClipboardService can then read that data to do something with it.

I think this implementation is a bit safer perhaps?
And the permission prompt can only be send once in a while to prevent spam.

Alternatively you can also include a “Never ask again” option.


this is a pretty good idea of how to implement it imo, a clipboard system would be nice though couldnt you just use no editable text boxes to copy stuff?

Editable text boxes is an option, I recall you can already do that in Roblox but it feels a bit cheap to do it that way.

I honestly also really wish Roblox had an API for prompting users to save or load a file.
Though, to prevent that from being harmful in any way the file would have to be raw text so it’s not possible to download a exe file or anything.

Just a simple and safe way to save certain things like user settings and whatnot locally would be nice.