How i can fix this script, The player need be cloned and sent to a local script but the character is not being cloned

The Script is not working because the character does not want to be cloned, only a nil appears in the console but if it detects that there is a character to be cloned.

i tried with a “CharacterAdded” but still giving the same result.

Here is the script if you wanna check it vvv

game.Players.PlayerAdded:Connect(function(Player)
        game.Workspace.ChildAdded:Connect(function(playerChar)
            ------------------------------------------------------
            print(playerChar)
      
            if playerChar.Name == Player.Name then
                local CharClone = playerChar:Clone()
                print(CharClone )
                CharClone.Parent = game.Workspace.CharacterSeat.Character
                
                game.Lighting.RemoteEvents.ClientEvent:FireAllClients(Player.Name,CharClone)
                    end
            ------------------------------------------------------
            
        end)
    end)

i have been trying to fix it but i dont know how to fix it, i think this is simple to fix
(Sorry for my english, i speak spanish)

Did you intend to do FireAllClients even though you’re firing to one specific player? Your code here should be:

game.Lighting.RemoteEvents.ClientEvent:FireClient(Player,CharClone)

I really don’t encourage putting RemoteEvents in game.Lighting, it should preferably be in game.ReplicatedStorage.
The first argument to FireClient is the player which (in theory) should be parent to game.Players

I don’t know what you’re trying to achieve though. If you’re trying to make a dummy of the player’s character, you should probably delete the localscripts inside the character (using a For loop), and set Archivable to false

Perhaps due to the Archivable property of the character model being false.

However, before you go changing it to true and cloning, there are a lot of reasons for it being false, as you likely don’t want all the character scripts and rubbish with it.

Can I ask the use case? It may be more appropriate to have a blank NPC rig and simply call
Humanoid:LoadDescription(player had:GetAppliedDescription()) on the humanoid of the NPC. That will make it look like the character and load accessories.

Side note: Player.CharacterAdded exists. You don’t need to check if every child added to the workspace has the same name as the player.

3 Likes

Thanks that worked!, i never tried to use arcivable property

1 Like