Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way that I can use "Humanoid:ApplyDescription()" locally?

Asked by
C1RAXY 81
1 year ago
Edited 1 year ago

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!

1
The ApplyDescription method can be used locally. xInfinityBear 1777 — 1y
1
'txt' is a boolean. The first parameter of the FocusLost event is a boolean to indicate whether enter was pressed. xInfinityBear 1777 — 1y
0
Nice observation in the txt, I fixed it! But the output says: "Humanoid::ApplyDescription() can only be called by the backend server" @xInfinityBear C1RAXY 81 — 1y
0
Hmm. I thought they already made this available on the client, my bad. Perhaps, try sending the UserId through the RemoteEvent and get the Humanoid Description from the server. xInfinityBear 1777 — 1y
0
Yes, it works but it's not achieving the goal to only replicate the specific event to the client that fired it C1RAXY 81 — 1y

1 answer

Log in to vote
1
Answered by
C1RAXY 81
1 year ago
Edited 1 year ago

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!

Ad

Answer this question