Unable to use Humanoid:ApplyDescription() to create a rig entirely on the client

Hello there! I am working on a game and as how many simulators / tycoons use NPC’s looking like their friends, I decided to try doing it. However when Applying the description to the rig, it errors that ‘it cannot be ran in the backend’.

I would like to note the fact that this code is written inside a ModuleScript and called on a LocalScript:

  • RigFriend - Main:
function RigFriend.LoadRigWithCharacterAppearance(UserId: number)
	local rig = replicatedStorage:WaitForChild("Assets").Rig_R6
	
	rig:Clone()
	rig.Parent = workspace.Rigs
	rig.Humanoid:ApplyDescription(players:GetHumanoidDescriptionFromUserId(UserId))
end
  • Client - Main
RIGFRIEND.LoadRigWithCharacterAppearance(players:GetUserIdFromNameAsync(playerFriends[math.random(1, #playerFriends)]))

How could this be fixed?

1 Like

The issue is that :ApplyDescription() and :GetHumanoidDescriptionFromUserId() are server-only, so when you try to use them from a LocalScript (or anything the client touches), it throws that “can’t be run in the backend” error.

What you’ll wanna do is move that part of the code — the bit where you get the HumanoidDescription and apply it — to a server-side script. You can still have your LocalScript request it, but the actual applying has to be done on the server.

One way to fix it:

Keep your ModuleScript on the server (like under ServerScriptService)

Create a RemoteEvent in ReplicatedStorage called like RequestFriendRig

From the LocalScript, fire that RemoteEvent and pass in the UserId

Then on the server, when it receives that event, it runs the code to clone the rig, get the description, apply it, and parent it to workspace

Super simple version of the server-side bit:

remote.OnServerEvent:Connect(function(player, userId)
	local rig = replicatedStorage.Assets.Rig_R6:Clone()
	local description = players:GetHumanoidDescriptionFromUserId(userId)

	rig.Parent = workspace.Rigs
	rig.Humanoid:ApplyDescription(description)
end)

Then from the client:

remote:FireServer(friendUserId)

1 Like

The main problem is I want the rig to be client side so no one else other than the player see’s the rig.

Not sure if you could apply the Description from the Server but I’ll try.

Edit: Thank you very much for the help! I have fixed the issue and implemented the rigs to be client only!

1 Like

no problem! good luck for the game!

1 Like