Need help with rig.Humanoid:ApplyDescription(desc)

So, i’m making a avatar editor and i want a rig to take form of the local player character only in the client side, ive heard that :ApplyDescription function now works in local scripts if the rig is cloned (created by the local script) and its true the function itself technically would work, the issue here is that in my script i’m getting a random error saying that the userId of the local player is nil? which im quiet confused about, and i have no clue how to fix this, i looked everyone online and its incredible how very little people talk about this issue or this inbuilt function itself, this person right here had a similar issue like me but i couldnt find any solutions there either

the script :

wait(3)

local Camera = workspace.CurrentCamera
local FocusPart = game.Workspace:FindFirstChild("AvatarEditorCamera")
local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local remoteEvent = ReplicatedStorage:WaitForChild("AvatarEditorCamera")
local SoundService = game:GetService("SoundService")
local ambientSound1 = SoundService["Day Ambience"]
local ambientSound2 = SoundService["Night Ambience"]
local Lighting = game:GetService('Lighting')

local function SetupGUI()
	local XButton = game.Players.LocalPlayer.PlayerGui.AvatarEditorGui.XButton
	local EditButton = player.PlayerGui.AvatarEditorGui.EditMenuButton

	XButton.Visible = true
	EditButton.Visible = true

	local character = player.Character
	local Humanoid = character:WaitForChild("Humanoid")
	Humanoid.WalkSpeed = 0
end

remoteEvent.OnClientEvent:Connect(function(player, desc)
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = FocusPart.CFrame
	SetupGUI()
	local sound = Instance.new("Sound")
	sound.SoundId = "rbxassetid://14826291316" 
	sound.Parent = game.Workspace
	sound.Looped = true
	sound.Volume = 0.25
	sound.Name = "AvatarEditorMusic"
	sound:Play()
	if ambientSound1.IsPlaying == true then
		ambientSound1:Pause()
	elseif ambientSound2.IsPlaying == true then
		ambientSound2:Pause()
	end
	local rig = ReplicatedStorage:WaitForChild("AvatarEditorCharacter")
	rig:Clone()
	rig.Parent = workspace
	local newCFrame = CFrame.new(480.75, -59, 105)
	rig:PivotTo(newCFrame)
	local desc = Players:GetHumanoidDescriptionFromUserId(player.UserId)

	rig.Humanoid:ApplyDescription(desc)
end)

the relevant part of the script :

	local desc = Players:GetHumanoidDescriptionFromUserId(player.UserId)

	rig.Humanoid:ApplyDescription(desc)

and finally, the error in the output :

 Players.Frosleko.PlayerScripts.AvatarEditorCAMscript:47: attempt to index nil with 'UserId'  -  Client - AvatarEditorCAMscript:47

if anyone can help me with this or notice any other errors ive made in my script please feel free to tell me, i appreciate

1 Like

Try using game:GetService("Players").LocalPlayer instead, as roblox tends to not give you the local player by using game.Players.LocalPlayer sometimes

1 Like

Unfortunately it still doesnt work, the same error is here

I think it’s because the player argument has the same variable name as the one mentioned above.
Try changing the argument to _player or something that the code can use.

oh right i forgot about those variables inside the function parenthesis, well your solution kinda worked cause the error is gone now but i got another that i thought would be patched, since, idk, years ago? according to that post we should be able to call ApplyDescription() inside a local script if the object has been created by the client but for some reason i apperently cant

the new error now :

 Humanoid::ApplyDescription() can only be called by the backend server

i’m kinda confused by what backend means and its crazy how there is very little info about it online
and because this error is back, i assume rig:Clone() is now useless cause not only it didnt even clone anything but apperently local scripts can’t clone models, so the whole " ermmm ApplyDescription() CAN be used inside local scripts… the objects humanoids just have to be created by the local script itself…" post is wrong.

it just means that ApplyDescription only works on server side (Backend)

unless the entire character is on the client side only

which means it can’t exist on the server side

the documentation isn’t wrong, i got this to work fine on my projects

1 Like

No, it’s not. I went over and tested the API myself, and you can apply humanoid description with a client-side cloned model.

And you also cant call the function on client-side with non-client sided models. (basically models that aren’t made/cloned on client)

That is because you didn’t define a variable when you cloned it. When you use Clone it returns the cloned instance, so you may want to use local rig = ReplicatedStorage:WaitForChild("AvatarEditorCharacter"):Clone() instead

local rig = ReplicatedStorage:WaitForChild("AvatarEditorCharacter"):Clone() -- Do this instead.
rig.Parent = workspace
local newCFrame = CFrame.new(480.75, -59, 105)
rig:PivotTo(newCFrame)
local desc = Players:GetHumanoidDescriptionFromUserId(player.UserId)

rig.Humanoid:ApplyDescription(desc)
1 Like

@Korbloxster @RuizuKun_Dev it is actually mindblowing how stupid i am, i did not understand the cloud logic very well and i should read twice the documentation before talking big, thank you so much the script is finally working now

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.