Skip to content

Commit 60cf049

Browse files
Update EXAMPLES.md
1 parent c7fbbb8 commit 60cf049

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

.github/docs/EXAMPLES.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,20 @@ Disclaimer: The client only loads the mod list from the server a few seconds aft
103103
```lua
104104
local mod = exports.newmodels:getModDataFromID(theID)
105105
```
106+
107+
## Spawning a player properly
108+
109+
You always need to pass a model ID to the `spawnPlayer` function, which it sets.
110+
111+
If you want to re-spawn a player and keep its custom skin ID, you need to unset it then set it again, in order for the changes to take effect.
112+
113+
**Server code:**
114+
115+
```lua
116+
local data_name = exports.newmodels:getDataNameFromType("player")
117+
local id = tonumber(getElementData(player, data_name))
118+
if id then
119+
removeElementData(player, data_name)
120+
setElementData(source, data_name, id)
121+
end
122+
```

0 commit comments

Comments
 (0)