how do I spawn a player avatar using id or username, thx
There’s a plugin for that, very useful if asking me
no I what to do that using lua for my game
If you want to spawn the player through studio, there are plugins that allow you to do that (Moon Animator 2, Load character, etc)
If you want to spawn the avatar through a script mid game, you can use
local userID = 1
game:GetService("Players"):CreateHumanoidModelFromUserId(userID).Parent = workspace
Well you just have to use the insert service. This script allows you to spawn the player wherever you wish and at anyime just by completing the function
local InsertService = game:GetService(“InsertService”)
local Players = game:GetService(“Players”)local userId = 12345678
local success, model = pcall(function()
return InsertService:LoadAsset(userId)
end)if success and model then
model.Parent = workspace
model:MoveTo(Vector3.new(0, 10, 0))
else
warn(“Failed to load avatar for user ID:”, userId)
end
(I’d suggest you also adding a warning for further notices and clearance)
yeah that works, but if i’d like to get the avatar as a variable how would that be done? thx
local userID = 1
local avatar = game:GetService("Players"):CreateHumanoidModelFromUserId(userID)
avatar.Parent = workspace
Should work