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