I am trying to make a game where you type in the username of a player and click play and it will do an animation As That Player.
You can use the :GetHumanoidDescriptionFromUserId method of the Players
container as the foundation for this project.
The function returns a HumanoidDescription Object that contains the asset information of a linked Character retrieved by UserId
cross-referencing. By using the :ApplyDescription() method of Humanoid
, we can supply the HumanoidDescription
Instance to actively draw the avatar of a Player onto a Model.
With a little filtering to derive the UserId of the Player Object pulled from our TextBox
, and locating our Model's Humanoid, we can put everything together:
local Players = game:GetService("Players") local AnimationModel = workspace:WaitForChild("AnimationModel") local TextBox = script.Parent local Button = TextBox:WaitForChild("PlayAnimation") local CurrentDescription; local function UpdatePlayerDescription(Return) if not (Return) then return end local Player = Players:FindFirstChild(TextBox.Text) if (Player) then local UserId = Player.UserId CurrentDescription = Players:GetHumanoidDescriptionFromUserId(UserId) end end local function SetModelDescription() local ModelHumanoid = AnimationModel:FindFirstChildOfClass("Humanoid") if (ModelHumanoid) then ModelHumanoid:ApplyDescription(CurrentDescription) end end TextBox.FocusLost:Connect(UpdatePlayerDescription) Button.MouseButton1Click:Connect(SetModelDescription)
This is convenient as we're manipulating the Humanoid
, which means Animation Loading and everything else will be pretty simple to integrate into this Script.
• Extra Resources:
If this helped, don't forget to accept this answer!