# llSetObjectName

*LSL function*

```lsl
void llSetObjectName(string name);
```

- `string name`: New name string.

- Energy: 10

Sets the prim's name according to the **name** parameter.

If this function is called from a child prim in a linked set, it will change the name of the child prim and not the root prim.

```lsl title="How to use" frame="terminal"
llSetObjectName("");
```

## Caveats

- The name is limited to 63 characters. Longer prim names are cut short.
- Names can only consist of the 95 printable characters found in the [ASCII-7](http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters) (non-extended) character set, with the exception of the vertical bar/pipe ("|") character.
  - Invalid characters in the range 1 to 31, as well as the pipe character (124) are replaced with a question mark ("?").
  - Other invalid characters in the range 128 and above are replaced with two or more question marks, depending on how many bytes their UTF-8 representation requires.
  - Objects with all-whitespace names (e.g., a space or a series of spaces) will appear as "(Unnamed)" if they emit chat via [llSay](/functions/llSay/), [llOwnerSay](/functions/llOwnerSay/), [llInstantMessage](/functions/llInstantMessage/), etc., although this behaviour may vary in third-party viewers.
- While an object is attached, the script cannot change the name of the object as it appears in the user's inventory.[^wiki-139711]
  - Changes to the name of the root prim (with [llSetObjectName](/functions/llSetObjectName/) for example) will not be saved to inventory; when the attachment is detached (to inventory, not dropped) this name change is discarded and the name in inventory is used instead.
  - When attachment is dropped (to the ground) and taking it into inventory, the inventory item will have the new name (not the old).
- Changes to the names of child prims will be saved back to inventory when the object is detached to inventory. They survive detachment.
- Changes to the object name do not trigger a [changed](/events/changed/) event.

[^wiki-139711]: Whether or not this is a bug is still debated, regardless LL has said they will not fix it. This behavior was first recognized as a pain point in [2006](http://forums-archive.secondlife.com/255/ab/84853/1.html) and only confirmed to be lava-flowed [more recently (2011)](https://jira.secondlife.com/browse/SVC-3429?focusedCommentId=267372&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-267372).

## Examples

<table>
	<tr>
		<th>**Set this prim's name**</th>
		<th>**Set the root prim's name**</th>
	</tr>
	<tr>
		<td>

			```lsl
			default
			{
			    state_entry()
			    {
			        llSetObjectName("NEW PRIM NAME");
			    }
			}
			```

		</td>
		<td>

			```lsl
			default
			{
			    state_entry()
			    {
			        llSetLinkPrimitiveParamsFast(LINK_ROOT,
			            [PRIM_NAME, "NEW ROOT PRIM NAME"]);
			    }
			}
			```

		</td>
	</tr>
	<tr>
		<th colspan="2">**Test if a string is valid as an object name**</th>
	</tr>
	<tr>
		<td colspan="2">

			```lsl
			// Returns TRUE if 'name' is a valid object name, FALSE otherwise
			integer isValidObjectName(string name)
			{
			    string original_name = llGetObjectName();
			    llSetObjectName(name);
			    integer valid_name = llGetObjectName() == name;
			    llSetObjectName(original_name);
			    return valid_name;
			}
			```

		</td>
	</tr>
</table>

## See also

### Functions

- [llGetObjectName](/functions/llGetObjectName/) — Get the prims name
- [llGetLinkName](/functions/llGetLinkName/) — Get a linked prims name
- [llGetObjectDesc](/functions/llGetObjectDesc/) — Get the prims description
- [llSetObjectDesc](/functions/llSetObjectDesc/) — Set the prims description
- [llGetObjectDetails](/functions/llGetObjectDetails/) — Get a list of object details

---

*Source: [LlSetObjectName](https://wiki.secondlife.com/wiki/LlSetObjectName) on the Second Life Wiki. Content from the Second Life Wiki articles LlSetObjectName (revision 1218374, 2025-07-25) and Template:LSL Function/limits (revision 1168817, 2012-06-11), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llSetObjectName/
