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

Why is the Clone of every Character nil?

Im trying to send a clone of every Character in the game to a folder inside every player. I tried doing this:

--This is a ServerScript
game.Players.PlayerAdded:Connect(function(plr)
	local Char = (plr.Character or plr.CharacterAdded:Wait())
	local CharClone = Char:Clone()
	game.ReplicatedStorage.Remotes.CloneSent:FireAllClients(CharClone)
end)

And this:

--This is a Local Script
game.ReplicatedStorage.Remotes.CloneSent.OnClientEvent:Connect(function(Clone)
	if Clone ~= nil
	then
	 Clone.Parent = script.Parent.Clones
	end
end)

But everytime I try to grab the clone on the Client, it has the value nil. Why? What should I do instead?

1 comment

0

The clone has to be static tho, so its not allowed to be moveable

1 answer

The player's Character's Archivable property is set to false by default, which makes Clone return nil. You'll have to set it to true for it to work, so it'll look like this:

--This is a ServerScript
game.Players.PlayerAdded:Connect(function(plr)
    local Char = (plr.Character or plr.CharacterAdded:Wait())
    Char.Archivable = true
    local CharClone = Char:Clone()
    game.ReplicatedStorage.Remotes.CloneSent:FireAllClients(CharClone)
end)

Hope this helped

6 comments

0

Now it stopped outputting that the char is nil, but the clone is still not parented to the given folder.Why?

0

You're parenting it inside the LocalScript. Try parenting it inside the ServerScript and it should work. There's no reason why the client would have to control the parent of the clone.

0

But the folder is local tho...

0

Why is the folder local? There's no point in it being local...

1

Instances that have no parent aren't replicated to players so OnClientEvent will receive nil. You have to parent it somewhere on the server where the client can see it

0

replication big dumb

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