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

Why is player not being cloned and C a nil Value?

While working on a script to clone the player's character I've come across the problem that its not cloning. What am I doing wrong here?

script.Parent.Touched:Connect(function(part)
	local Players = game:GetService("Players")
	local player = Players:GetPlayerFromCharacter(part.Parent)
	wait(1)
	part.Reflectance = 0.2 
	wait(3)
	part.Reflectance = 0.4
	wait(3)
	part.Reflectance = 0.6
	wait(3)
	part.Reflectance = 0.8
	wait(5)
	part.Reflectance = 1
	
	local function crystalize()
		if player.Character then
			local c = player.Character:Clone()
			c.Parent = workspace
			c.Name = "SCP-409-1("..player.Name..")"

			local d = c:GetChildren()
			for i = 1, #d do 
				if d[i].className == "Accessory" then 
					d[i].Mesh.TextureId = "http://www.roblox.com/asset/?id=686337933"
					d[i].Handle.Transparency = 0
					d[i].Anchored = true
				end
				if d[i].className == "Part" then 
					if d[i].Name ~= "HumanoidRootPart" then
						d[i].Anchored = true
						d[i].Transparency = 0
						if d[i].Name == "Head" then
							if d[i]:FindFirstChild("face") then
								d[i].face:Destroy()
							end
						end
					end
				end
			end
		end
		player.Torso:Destroy()
	end
	crystalize(part)
end)

EDIT: Put the full script opposed to the cut out.

Output: Workspace.SCPs.SCP-409.Freeze:19: attempt to index local 'c' (a nil value)

12 comments

1

With the players model you need to set Archivable to true before cloning the player.

0

It is set true but still nothing. If I need to post the whole script I can.

0

You probably also need to set the position of the model or it may just be falling off the map

0

All the original parts from the player are anchored before the clone is made.

0

What is "part"? Is this is a global? If it's from a touched event, it isn't being passed to your function "crystalize()". Include it by doing "crystalize(part)".

0

crystalize is in the function where local part is defined. Also tried crystal(part) and still getting the same thing.

0

Because, you really never got the character...

0

Can you that code as well? (The part where part is defined and function is called.)

0

If I need to I can post the full code if it makes things any easier.

0

Yes please

0

I edited the question desc and put the full script there.

0

Try making sure that it's a humanoid touching the part?

1 answer

✓ Accepted answer

Try enabling "Archivable " right before you clone it.

(Line 17-ish):


local character = player.Character

character.Archivable = true
		
local c = character:Clone()
		
character.Archivable = false

1 comment

1

That seemed to do the trick. Thank you!

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