In-Game Editable Image Publishing


Hi Creators :cactus::smiling_face:

We’re excited to announce some updates to our In-Game Asset Creation system!

What’s Changing?

  1. API Method Rename: We have renamed the previous prompt publish asset method to AssetService:PromptCreatePlatformContentAsync, and updated it to take in an Object instead of an Instance. This update sets a cleaner standard for how in-game creation and publishing prompts will function moving forward.

  2. Image Publishing Is Live! As of today, uploading an EditableImage directly through PromptCreatePlatformContentAsync is fully released and live! Published images go straight to the player’s inventory, allowing them to use their creations across other Roblox experiences or even off-platform.

Here’s a code snippet to try it out. This one draws the Roblox logo directly from a ServerScript and prompts the player to upload it.

Click to see the code snippet:
local AssetService = game:GetService("AssetService")
local Players = game:GetService("Players")

local BLUE = {49, 86, 255}
local WHITE = {255, 255, 255}

local SIZE = 400
local CENTER = SIZE / 2
local OUTER_HALF = 100
local INNER_HALF = 28
local ANGLE = math.rad(15)

local COS = math.cos(ANGLE)
local SIN = math.sin(ANGLE)

local SAMPLES = 4

local function isInsideSquare(x, y, halfSize)
	return math.abs(x) <= halfSize
		and math.abs(y) <= halfSize
end

local function generateLogo()
	local editableImage = AssetService:CreateEditableImage({
		Size = Vector2.new(SIZE, SIZE),
	})

	if not editableImage then
		warn("Could not create EditableImage. Make sure access to the Editable Mesh / Image apis is enabled.")
		return nil
	end

	local pixels = buffer.create(SIZE * SIZE * 4)

	for py = 0, SIZE - 1 do
		for px = 0, SIZE - 1 do
			local whiteSamples = 0

			-- Test subpixel positions to antialias the edges.
			for sy = 0, SAMPLES - 1 do
				for sx = 0, SAMPLES - 1 do
					local screenX = px + (sx + 0.5) / SAMPLES - CENTER
					local screenY = py + (sy + 0.5) / SAMPLES - CENTER

					-- Undo the square's clockwise rotation.
					local x = screenX * COS + screenY * SIN
					local y = -screenX * SIN + screenY * COS

					local outer = isInsideSquare(x, y, OUTER_HALF)
					local inner = isInsideSquare(x, y, INNER_HALF)

					if outer and not inner then
						whiteSamples += 1
					end
				end
			end

			local coverage = whiteSamples / (SAMPLES * SAMPLES)
			local offset = (py * SIZE + px) * 4

			for channel = 1, 3 do
				local background = BLUE[channel]
				local foreground = WHITE[channel]

				local value = background
					+ (foreground - background) * coverage

				buffer.writeu8(pixels, offset + channel - 1,
					math.floor(value + 0.5))
			end

			buffer.writeu8(pixels, offset + 3, 255)
		end
	end

	editableImage:WritePixelsBuffer(
		Vector2.zero,
		Vector2.new(SIZE, SIZE),
		pixels
	)

	return editableImage
end

Players.PlayerAdded:Connect(function(player)
	-- CoreGui needs to be loaded for the Prompt method to work.
	player.CharacterAdded:Wait()
	
	local logo = generateLogo()
	
	local success, result, assetId = pcall(function()
		return AssetService:PromptCreatePlatformContentAsync(player, logo, Enum.AssetType.Image)
	end)

	if success then
		print("Published successfully! Result:", result, "AssetId:", assetId)
	else
		warn("Failed to publish image:", result)
	end
end)

Note: If you’re testing this out in Studio, make sure you’re testing in a published place - it will fail otherwise. Your game must also have the “Allow Mesh / Image APIs” setting enabled.

Here’s one thats a bit more interactive! It requires a bit of setup

  1. Create a RemoteEvent called PublishDrawing in ReplicatedStorage

  2. Add the following LocalScript to StarterPlayerScripts. It handles user interaction and on publish, writes the EditableImage to a buffer and sends it over the RemoteEvent to be handled by the server.

Click to see the code snippet:
-- LocalScript in StarterPlayer > StarterPlayerScripts

local Players = game:GetService("Players")
local AssetService = game:GetService("AssetService")
local UserInputService = game:GetService("UserInputService")

local player = Players.LocalPlayer

-- Configuration
local CANVAS_SIZE = 256
local BRUSH_RADIUS = 5
local BACKGROUND = Color3.fromRGB(255, 255, 255)

local COLORS = {
	Color3.fromRGB(25, 25, 35),
	Color3.fromRGB(255, 70, 70),
	Color3.fromRGB(255, 170, 40),
	Color3.fromRGB(255, 220, 60),
	Color3.fromRGB(70, 200, 110),
	Color3.fromRGB(50, 130, 255),
	Color3.fromRGB(160, 90, 255),
	Color3.fromRGB(255, 110, 200),
	Color3.fromRGB(255, 255, 255),
}

-- Helpers
local function make(className, props, parent)
	local object = Instance.new(className)
	for key, value in pairs(props) do
		object[key] = value
	end
	object.Parent = parent
	return object
end

local function round(gui, radius)
	make("UICorner", {
		CornerRadius = UDim.new(0, radius),
	}, gui)
end

-- UI
local gui = make("ScreenGui", {
	Name = "PixelArtStudio",
	ResetOnSpawn = false,
}, player:WaitForChild("PlayerGui"))

local panel = make("Frame", {
	Name = "Panel",
	Size = UDim2.fromOffset(440, 520),
	Position = UDim2.new(0.5, -220, 0.5, -260),
	BackgroundColor3 = Color3.fromRGB(29, 31, 42),
	BorderSizePixel = 0,
}, gui)
round(panel, 14)

make("TextLabel", {
	Size = UDim2.new(1, -32, 0, 42),
	Position = UDim2.fromOffset(16, 8),
	BackgroundTransparency = 1,
	Text = "Draw Something!",
	TextColor3 = Color3.new(1, 1, 1),
	Font = Enum.Font.GothamBold,
	TextSize = 22,
	TextXAlignment = Enum.TextXAlignment.Left,
}, panel)

-- Editable canvas
local editableImage = AssetService:CreateEditableImage({
	Size = Vector2.new(CANVAS_SIZE, CANVAS_SIZE),
})

if not editableImage then
	warn("Could not create EditableImage. Check Mesh / Image API permissions.")
	gui:Destroy()
	return
end

editableImage:DrawRectangle(
	Vector2.zero,
	Vector2.new(CANVAS_SIZE, CANVAS_SIZE),
	BACKGROUND,
	0,
	Enum.ImageCombineType.Overwrite
)

local canvas = make("ImageLabel", {
	Name = "Canvas",
	Size = UDim2.fromOffset(320, 320),
	Position = UDim2.fromOffset(60, 78),
	BackgroundColor3 = BACKGROUND,
	BorderSizePixel = 0,
	ImageContent = Content.fromObject(editableImage),
	ScaleType = Enum.ScaleType.Fit,
	Active = true,
}, panel)

make("UIStroke", {
	Color = Color3.fromRGB(80, 85, 105),
	Thickness = 2,
}, canvas)

-- Palette
local palette = make("Frame", {
	Size = UDim2.new(1, -32, 0, 36),
	Position = UDim2.fromOffset(16, 412),
	BackgroundTransparency = 1,
}, panel)

make("UIListLayout", {
	FillDirection = Enum.FillDirection.Horizontal,
	HorizontalAlignment = Enum.HorizontalAlignment.Center,
	VerticalAlignment = Enum.VerticalAlignment.Center,
	Padding = UDim.new(0, 7),
}, palette)

local selectedColor = COLORS[1]
local erasing = false

local function selectColor(color)
	selectedColor = color
	erasing = color == BACKGROUND
end

for _, color in ipairs(COLORS) do
	local swatch = make("TextButton", {
		Size = UDim2.fromOffset(28, 28),
		BackgroundColor3 = color,
		BorderSizePixel = 0,
		Text = "",
		AutoButtonColor = true,
	}, palette)

	round(swatch, 7)

	if color == COLORS[1] then
		make("UIStroke", {
			Color = Color3.new(1, 1, 1),
			Thickness = 2,
		}, swatch)
	end

	swatch.Activated:Connect(function()
		selectColor(color)
	end)
end

-- Controls
local controls = make("Frame", {
	Size = UDim2.new(1, -32, 0, 40),
	Position = UDim2.fromOffset(16, 456),
	BackgroundTransparency = 1,
}, panel)

make("UIListLayout", {
	FillDirection = Enum.FillDirection.Horizontal,
	HorizontalAlignment = Enum.HorizontalAlignment.Center,
	Padding = UDim.new(0, 8),
}, controls)

local function makeButton(text, color, callback)
	local button = make("TextButton", {
		Size = UDim2.fromOffset(120, 36),
		BackgroundColor3 = color,
		BorderSizePixel = 0,
		Text = text,
		TextColor3 = Color3.new(1, 1, 1),
		TextSize = 13,
		Font = Enum.Font.GothamBold,
		AutoButtonColor = true,
	}, controls)

	round(button, 8)
	button.Activated:Connect(callback)
	return button
end

local status = make("TextLabel", {
	Size = UDim2.new(1, -32, 0, 18),
	Position = UDim2.fromOffset(16, 498),
	BackgroundTransparency = 1,
	Text = "Ready to draw!",
	TextColor3 = Color3.fromRGB(165, 200, 180),
	Font = Enum.Font.Gotham,
	TextSize = 11,
	TextXAlignment = Enum.TextXAlignment.Left,
}, panel)

makeButton("Clear", Color3.fromRGB(75, 80, 100), function()
	editableImage:DrawRectangle(
		Vector2.zero,
		Vector2.new(CANVAS_SIZE, CANVAS_SIZE),
		BACKGROUND,
		0,
		Enum.ImageCombineType.Overwrite
	)
	status.Text = "Canvas cleared!"
end)

makeButton("Eraser", Color3.fromRGB(95, 80, 130), function()
	erasing = true
	selectedColor = BACKGROUND
	status.Text = "Eraser selected"
end)

makeButton("Publish", Color3.fromRGB(45, 125, 235), function()
	status.Text = "Sending drawing..."

	local pixels = editableImage:ReadPixelsBuffer(
		Vector2.zero,
		Vector2.new(256, 256)
	)

	game:GetService("ReplicatedStorage")
		:WaitForChild("PublishDrawing")
		:FireServer(pixels)

	status.Text = "Drawing sent to server."
end)

-- Drawing input
local drawing = false
local lastPosition = nil

local function getCanvasPosition(screenPosition)
	local origin = canvas.AbsolutePosition
	local size = canvas.AbsoluteSize

	local x = screenPosition.X - origin.X
	local y = screenPosition.Y - origin.Y

	if x < 0 or y < 0 or x >= size.X or y >= size.Y then
		return nil
	end

	return Vector2.new(
		x * CANVAS_SIZE / size.X,
		y * CANVAS_SIZE / size.Y
	)
end

local function draw(screenPosition)
	local position = getCanvasPosition(screenPosition)
	if not position then
		lastPosition = nil
		return
	end

	local color = erasing and BACKGROUND or selectedColor

	if lastPosition then
		editableImage:DrawLine(
			lastPosition,
			position,
			color,
			0,
			Enum.ImageCombineType.Overwrite,
			Enum.AntiAliasing.Disabled
		)
	end

	editableImage:DrawCircle(
		position,
		BRUSH_RADIUS,
		color,
		0,
		Enum.ImageCombineType.Overwrite,
		Enum.AntiAliasing.Disabled
	)

	lastPosition = position
end

canvas.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1
		or input.UserInputType == Enum.UserInputType.Touch then

		drawing = true
		lastPosition = nil
		draw(input.Position)
	end
end)

canvas.InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1
		or input.UserInputType == Enum.UserInputType.Touch then

		drawing = false
		lastPosition = nil
	end
end)

UserInputService.InputChanged:Connect(function(input)
	if not drawing then
		return
	end

	if input.UserInputType == Enum.UserInputType.MouseMovement
		or input.UserInputType == Enum.UserInputType.Touch then
		draw(input.Position)
	end
end)

UserInputService.InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1
		or input.UserInputType == Enum.UserInputType.Touch then
		drawing = false
		lastPosition = nil
	end
end)
  1. Add the following Script to ServerScriptService (this calls PromptCreatePlatformContentAsync when the PublishDrawing is fired, since it can only be invoked from the server). It recreates the EditableImage on the server from the buffer sent over by the LocalScript.
Click to see the code snippet:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AssetService = game:GetService("AssetService")

local publishEvent = ReplicatedStorage:WaitForChild("PublishDrawing")

local IMAGE_SIZE = 256
local MAX_BYTES = IMAGE_SIZE * IMAGE_SIZE * 4

publishEvent.OnServerEvent:Connect(function(player, pixelBuffer)
	if typeof(pixelBuffer) ~= "buffer" then
		return
	end

	if buffer.len(pixelBuffer) ~= MAX_BYTES then
		warn("Invalid drawing buffer from", player.Name)
		return
	end

	local editableImage = AssetService:CreateEditableImage({
		Size = Vector2.new(IMAGE_SIZE, IMAGE_SIZE),
	})

	if not editableImage then
		warn("Unable to create EditableImage")
		return
	end

	local success, err = pcall(function()
		editableImage:WritePixelsBuffer(
			Vector2.zero,
			Vector2.new(IMAGE_SIZE, IMAGE_SIZE),
			pixelBuffer
		)
	end)

	if not success then
		warn("Failed to reconstruct drawing:", err)
		editableImage:Destroy()
		return
	end


	local ok, result, assetId = pcall(function()
		return AssetService:PromptCreatePlatformContentAsync(
			player,
			editableImage,
			Enum.AssetType.Image
		)
	end)

	if not ok then
		warn("Publishing prompt failed:", result)
	elseif result then
		print("Publish result:", result, assetId)
	end

	editableImage:Destroy()
end)

Safety, Moderation and Ownership

  • Persisted content might be moderated after the fact so you should not assume that the AssetID you get back will always work
  • Players fully own that content from now on and they can do whatever they see fit with it (export it, build another game etc.)
  • Images uploaded via this API have their privacy set to Open Use. Read more about asset privacy here: Asset privacy | Documentation - Roblox Creator Hub

We can’t wait to see the creative tools, drawing canvases, and customized content you build for your players. As always, let us know if you have any questions or feedback. Thank you! :artist_palette::sparkles:

FAQs

What happened to the old prompt publish asset methods?

  • They have been deprecated and renamed to PromptCreatePlatformContentAsync to better align with platform standards as we expand creation capabilities. The method also takes in an Object, which allows us to take in an EditableImage directly instead of an instance.

Which asset types are supported right now?

  • Currently, support is enabled for EditableImages.

What asset type is coming next?

  • What asset type should come next? Audio? Meshes?
105 Likes

This topic was automatically opened after 11 minutes.

Great feature, however I got two questions:

  • Will the experience ever face moderation action for the drawing the user has submitted, in any way? I can imagine some experiences retaining the buffer information of the image for other purposes, so I wanted to ask.
  • Any updates on lifting the ID verification requirement for Editable* APIs?

Next up we should be able to publish EditableMeshes. That aside, last time I heard, an EditableSound API wasn’t being considered, if it is now, then that’s great.

23 Likes

Still biding my time for models, I have built an entire export workflow for my 3D building game which lets players take their creations out into studio with a companion plugin via a base64 string. Would be nice not to need all that.

6 Likes

This is very interesting, could this mean we can make drawing games with this and allow people to share their drawings?

Drawing games are locked to 16+ will this be policy compliant if this is used instead? I am a little worried though, could this get people banned? I can see this opening up new methods to get people banned (like hiding an offensive symbol in the image)

I have feature requests about this topic and would love to speak more about it if possible!

5 Likes

A few Qs.

  • Can we overwrite AssetIDs with this?
  • Are “owned” assets subject to asset privacy - so it’s not possible to re-load it back into an editable image and modify it?

Number 2 is a big minus if so

2 Likes

What’s if developer intentionally scripts the game to create an inappropriate drawing and save it to player inventory after player clicks a malicious button in game? Wouldn’t this create an issue where people will end up getting banned for joining a completely drawing unrelated game?

8 Likes

YESSSS FINALLLYY OH MY GOD, i have been waiting for this for SO long i love YOUUU

2 Likes

If moderation fails, does it have any impact on the player specifically at the moment of upload? It would be a real shame to receive a warning (or a ban) if an asset gets blocked during the upload process.

1 Like

The image is shown in the coregui modal before the player saves it.

Would be different for 3D models since the player can’t rotate and slice and inspect them.

3 Likes

The prompt exists for a reason. The experience cannot save to the player’s inventory directly, it prompts the player to complete the saving process.

2 Likes

that sounds like something that already happend to people thru CaptureService account terminations

it blew up on twitter very quick once it hit verified people (which then after roblox gave them appeal priority after the drama or smth idk)

Roblox as a company is constantly failing to protect us the community from these exploits even when reported to them they just ghost you for months with no response

3 Likes

i disagree with you because bad actors clickjacked people into pressing publish with CaptureService before and got a lot of accounts terminated

you must be living under a rock if you don’t know this because it blew up on twitter very quick months ago

1 Like

Meshes should definitely be supported asap, as for audios that’s a bit strange, how would devs be able to do that.. unless there’s some super secret upcoming EditableAudio instance type :eyes:

1 Like

I didn’t state an opinion, there is no API available that allows you to directly save to the player’s inventory, comparing it to an oversight which got amended later isn’t the same.

2 Likes

Once again bad actors will just clickjack innocent people and get their accounts terminated just like how it happend last time

don’t believe me? check these threads out

1 Like

@gravitycoil828 thought i’d mention you here since you were talking about this in another post

2 Likes

Glad this is finally possible, though I have a few questions:

  • Why can this only create an Image asset, without a corresponding Decal asset? Decals are important because you can archive them. You cannot directly archive Images.

  • If the user has asset privacy enabled in their Creator Hub settings, the Image’s privacy will be “Restricted”, which creates a lot of friction because, after uploading the image, I would have to tell the user to manually navigate to Creator Hub in a web browser, and manually set the Image’s privacy to “Open Use”, so that it can actually be displayed inside the game that they just created it from. I feel like assets created in-game should just automatically be “Open Use” no matter what.

  • Guidelines for “free-form user creation” specify that it does not apply to creations that go through Roblox moderation before they are published/replicated. Since this API forces the image to go through Roblox moderation, does this mean you can make an all-ages drawing game now, as long as you use this API before displaying user-generated images?

10 Likes

These are great questions!

  • Decals are a weird combo of assets and images together. Image is the underlying one, every decal has a corresponding image associated with it. We chose to upload the primitive image. I’ll check and see why we don’t support image archiving…
  • :thinking: Another good question. Also will have to check with someone. I’m not too familiar with the asset privacy system and how it works. I think if we take a cue from captures and capture permissions, it seems like we should be able to grant access to the associated experience.
  • Let me check with the team, i think you’re correct. One of the benefits of this API is it goes through normal image moderation, so i think if you required the image to be published to roblox before sharing with others, it may be fine, but i will need to clarify with the policy team. It’s whats given me confidence in my own experiments with this api to share content created from it off platform safely and was one of our intentions with adding this.
10 Likes

Is this a hint that we will eventually get EditableSound ???

2 Likes