Hi! Im making a TextBox
with the idea of making the player being able to input the username of another player (or the player ID) and a NPC gets the avatar from the user the player inputs from scratch. Since I don't have the intention to replicate it to other clients im using a LocalScript
and I get this error every time I try directly use it in the NPC humanoid "Humanoid::ApplyDescription() can only be called by the backend server"
, is there a way I can achieve this while being able to use ApplyDescription()
or ApplyDescriptionReset()
without replicating?
Edit: Code deleted to not confuse readers seeking for an answer which is below!
So I found the solution myself, for anyone that encounter this issue in the future, you can replace the humanoid (destroying the old one) creating a new Humanoid
and parenting the new one to the NPC you wish to change the description. This way you can use Humanoid:ApplyDescription()
or ApplyDescriptionReset()
locally without using server scripts or remotes.
Example:
local NPC = workspace:WaitForChild("NPC") local Plrs = game:GetService("Players") local NewHumanoid = Instance.new("Humanoid") NewHumanoid.Name = "NewHumanoid" NewHumanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None NewHumanoid.Parent = NPC NPC:WaitForChild("Humanoid"):Destroy() -- Replaces the humanoid deleting the old one. task.wait(2) local DescToUse = Plrs:GetHumanoidDescriptionFromUserId(376124796) NPC:FindFirstChildOfClass("Humanoid"):ApplyDescription(DescToUse) -- Bingo! It applies the description locally without replicationg to other clients
You can use ApplyDescriptionReset()
or ApplyDescription()
any time to change the description of your NPC without needing to create another Humanoid
instance.
Example 2:
-- + Code from above task.wait(2) local DescToUse = Plrs:GetHumanoidDescriptionFromUserId(376124796) NPC:FindFirstChildOfClass("Humanoid"):ApplyDescription(DescToUse) -- Applies my avatar task.wait(2) DescToUse = Plrs:GetHumanoidDescriptionFromUserId(1) NPC:FindFirstChildOfClass("Humanoid"):ApplyDescription(DescToUse) -- Applies Roblox's avatar
I hope this helps!