Owner only avatar

im trying to make a script that sets my current avatar to a rig i created when i spawn in, but only for myself. how would i go about doing it?

1 Like

When a character spawns, check to see if the player is you. If it is, clone the custom rig and set it as your character.

Something like this:

local player = game:GetService("Players").LocalPlayer
local customRig = game:GetService("ReplicatedStorage"):WaitForChild("CustomRig")

player.CharacterAppearanceLoaded:Connect(function(character)
    if player.UserId == 00000000 then  -- Replace with your UserId
        local newCharacter = customRig:Clone()
        newCharacter.Parent = workspace
        newCharacter.Name = player.Name
        newCharacter:SetPrimaryPartCFrame(character:GetPrimaryPartCFrame())
        player.Character = newCharacter
        character:Destroy()
    end
end)
2 Likes

where would i put this script exactly? in the workspace or in script services?

LocalScript inside of StarterPlayerScripts.

1 Like

ok so my avatar got replace with the rig and i can move it around but now i got some new problems, the camera doesnt follow the new rig or play any animations at all, how would i fix this exactly?
image
image

1 Like

Set the camera to follow the character by setting CameraSubject to the rig’s Humanoid and have animations play by adding an Animator inside the Humanoid.

local player = game:GetService("Players").LocalPlayer
local customRig = game:GetService("ReplicatedStorage"):WaitForChild("CustomRig")

player.CharacterAppearanceLoaded:Connect(function(character)
    if player.UserId == 00000000 then  -- Replace with your UserId
        local newCharacter = customRig:Clone()
        newCharacter.Parent = workspace
        newCharacter.Name = player.Name
        newCharacter:SetPrimaryPartCFrame(character:GetPrimaryPartCFrame())
        
        -- Set new character
        player.Character = newCharacter

        -- Make camera follow
        local humanoid = newCharacter:FindFirstChildOfClass("Humanoid")
        if humanoid then
            game.Workspace.CurrentCamera.CameraSubject = humanoid

            -- Ensure animations work
            if not humanoid:FindFirstChildOfClass("Animator") then
                Instance.new("Animator", humanoid)
            end
        end

        -- Remove old character
        character:Destroy()
    end
end)

ok i just tried it now and the camera is fixed! however animations are still broken but a bigger problem i got right now is that when i reset it just soft locks me (basically it wont respawn me once i die, im just stuck like this forever), how would i go about fixing it?

image

This should now respawn the character.

local player = game:GetService("Players").LocalPlayer
local customRig = game:GetService("ReplicatedStorage"):WaitForChild("CustomRig")

player.CharacterAppearanceLoaded:Connect(function(character)
    if player.UserId == 00000000 then  -- Replace with your UserId
        local newCharacter = customRig:Clone()
        newCharacter.Parent = workspace
        newCharacter.Name = player.Name
        newCharacter:SetPrimaryPartCFrame(character:GetPrimaryPartCFrame())
        
        -- Set new character
        player.Character = newCharacter

        -- Make camera follow
        local humanoid = newCharacter:FindFirstChildOfClass("Humanoid")
        if humanoid then
            game.Workspace.CurrentCamera.CameraSubject = humanoid

            -- Ensure animations work
            if not humanoid:FindFirstChildOfClass("Animator") then
                Instance.new("Animator", humanoid)
            end
        end

        -- Remove old character
        character:Destroy()

        -- Respawn
        player:LoadCharacter()
    end
end)

i added the new part of the script but i still dont respawn on reset, is there any other way to force a respawn?
image

Can you show how you have everything organized?

free scripting i see, great job for helping! :money_mouth_face: :money_mouth_face:


if you need to see anything else just ask
(oh and stuff in the baseplate is just a few models i made)

:LoadCharacter() is not usable on client and is intended for a server only, you’d have to separate that logic and place in a server side script or fire the remote to notify the server you want to load the character

also one thing here is that SetPrimaryPartCFrame() shouldn’t be used, it makes a huge network spike, just got for :PivotTo() or BulkMoveTo instead