#Trying to clone a player's character

49 messages · Page 1 of 1 (latest)

pastel whale
#

I am trying to clone a player's character but I keep getting an error while trying to modify the clone

local clone = targetPlayer.Character:Clone()
clone.Parent = game.Workspace
clone.Position = targetPlayer.HumanoidRootPart.CFrame

This is the error:
ServerScriptService.Commands.Main:151: attempt to index nil with 'Parent'

faint creek
#

can i see the ful script?

#

also send it in this format

pastel whale
#

I can show you the variables

faint creek
#

yea thats mostly what i need

pastel whale
#

Its kind of hard to show what it is but it is a player

faint creek
#

could you just send the whole code?

pastel whale
#

I dont really want anyone to copy it, its about 320 lines long

faint creek
#

oh, aright then

#

can you show me just the variable for targetPlayer then?

#

just that line

pastel whale
#

for _, targetPlayer in ipairs(targetPlayers) do

faint creek
#

i'll jsut assume that targetPlayers is defined right then

#

just searched it up

#

you need to make the clone archivable

#
local newPlayer = Chr:Clone()
newPlayer.Archivable = true
#

this is an example

pastel whale
#

Like this?

local clone = targetPlayer.Character:Clone()
clone.Archivable = true
clone.Parent = game.Workspace
clone.Position = targetPlayer.HumanoidRootPart.CFrame

faint creek
#

yea, that should work fine

pastel whale
#

now it prints this:

ServerScriptService.Commands.Main:151: attempt to index nil with 'Archivable'

faint creek
#

yikes

pastel whale
#

yes, it prints my username

faint creek
#

ok thats good

#

can you change it now to print out targetPlayer.parent?

pastel whale
#

yes, it prints "Players"

faint creek
#

ok thats good

#

oh i didnt read far enough into the thread i read

#

you have to add a task.wait() apparently

#

after setting the clone.Archivable to true

pastel whale
#

im going to try to set the charactor to archivable insted of the clone

faint creek
#

worth a shot

pastel whale
#

It clones now but it prints an error

faint creek
#

whats the error

pastel whale
#

HumanoidRootPart is not a valid member of Player "Players.abcabcabdab"

faint creek
#

is that on a later line?

pastel whale
#

its on the line "clone.Position = targetPlayer.HumanoidRootPart.CFrame"

faint creek
#

maybe do a :WaitForChild()?

#

oh

#

wait

#

you get the HumanoidRootPart from the character, not the player

#
clone.Position = targetPlayer.Character.HumanoidRootPart.CFrame
#

do that

pastel whale
#

I tried that and it prints a different error

Position is not a valid member of Model "Workspace.abcabcabdab"

faint creek
#
clone.HumanoidRootPart.CFrame = targetPlayer.Character.HumanoidRootPart.CFrame
#

that'll do the trick hopefully

pastel whale
#

It working now and it does not print any errors thank you for helping me

crimson isleBOT
#

studio** You are now Level 4! **studio

faint creek
#

yea ofc