Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I cant copy my character?

Ok so i was making a rpg game and i wanted to copy my character for a cutscene but i couldnt Heres the code:

game.Players.PlayerAdded:Connect(function(plr)
	local Char = game.Workspace:WaitForChild(plr.Name)
	print(Char)
	local Clone = game.Workspace:WaitForChild(plr.Name):Clone()
	Clone.Parent = game.Workspace
end)

And heres the output:

  ServerScriptService.Script:7: attempt to index nil with 'Parent'  -  Server  -  Script:7
  Stack Begin  -  Studio

How is it nil???

1 answer

✓ Accepted answer

You can't copy the player's character because the model's property called Archivable. It set it to false by default, and I don't recommend turning on Archivable as it is vulnerable to exploits. Instead use Players:GetCharacterAppearanceAsync() to get your data, and put on a blank NPC.

local NPC = workspace.NPC:Clone()
NPC.Parent = workspace
game.Players.PlayerAdded:Connect(function(player)
	local model = game.Players:GetCharacterAppearanceAsync(player.UserId)
	for i, v in pairs(model) do --This just loops through a table.
		v.Parent = NPC
	end
end)

1 comment

0

Dude ur smart thx

This discussion is preserved as it was. New answers, comments, and votes are closed.