PlayerCharacter ID don't load on Rig

I’m trying to put player character on a menu screen, script works but don’t load player character.

Script:

-- local Player = game.Players.LocalPlayer
local ReplicatedFirst = game:GetService("ReplicatedFirst")

repeat wait() until game:IsLoaded()

local PlayerCharacter = game.ReplicatedFirst.Rig:Clone()

PlayerCharacter.Parent = workspace

	PlayerCharacter:WaitForChild("Humanoid"):ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(game.Players.LocalPlayer.UserId))
	
PlayerCharacter:WaitForChild("Humanoid"):LoadAnimation(script.Animation):Play()

It seems like you’re trying to clone a player character and apply a specific HumanoidDescription to it. If the character isn’t loading, there could be a few reasons why:

  1. Existence of Elements: Ensure that the Rig exists in ReplicatedFirst and that it has a Humanoid child. Also, make sure that the Animation exists in the script’s parent.
  2. Timing: The game:IsLoaded() function checks if the base game has loaded, but it doesn’t guarantee that all services and their children (like the Rig in ReplicatedFirst) have finished loading. You might want to use WaitForChild for these elements as well.
  3. Permissions: Make sure the script has the necessary permissions to clone objects and parent them to the workspace.

Here’s a revised version that shows script checks:

-- Wait for the game to load
repeat wait() until game:IsLoaded()

-- Check if the Rig exists in ReplicatedFirst
if game:GetService("ReplicatedFirst"):FindFirstChild("Rig") then
    local PlayerCharacter = game:GetService("ReplicatedFirst").Rig:Clone()
    PlayerCharacter.Parent = workspace

    -- Check if the Humanoid exists in the PlayerCharacter
    if PlayerCharacter:FindFirstChild("Humanoid") then
        PlayerCharacter.Humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(game.Players.LocalPlayer.UserId))

        -- Check if the Animation exists in the script's parent
        if script:FindFirstChild("Animation") then
            PlayerCharacter.Humanoid:LoadAnimation(script.Animation):Play()
        else
            print("Animation not found in the script's parent.")
        end
    else
        print("Humanoid not found in the PlayerCharacter.")
    end
else
    print("Rig not found in ReplicatedFirst.")
end

This script includes checks to ensure that the Rig, Humanoid, and Animation all exist before they are used. If any of these elements do not exist, a message will be printed to the output window in Roblox Studio. This can help solve any issues with missing elements.

1 Like

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