Basically, what I want to achieve is for the code to pick a random player, clone them, then swap their body with the clone and take that actual player away, however with the code I have, It will not allow me to parent the clone to workspace, in return stating that “clone is a nil value” . Without the “:Clone()” at the end of local clone, it prints my name. What am I doing wrong ;o?
Code
wait(6)
local PlayerCount = game.Players:GetChildren()
local random = math.random(1,#game.Players:GetChildren())
local Chosen = PlayerCount[random]
local clone = Chosen.Character:Clone()
_G.P1 = Chosen
print(clone)
clone.Parent = workspace
clone.Name = "".. tostring(Chosen) .."2"
clone:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(102.225, 42.502, 1038.45)*CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(180), math.rad(0))
game.Workspace:FindFirstChild(tostring(Chosen)):FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(83.846, 4.6, 1017.737)
print(clone.name)
I know I’m going to facepalm when I hear the answer, but I’m tired right now so I can’t find it myself >.<
@ileph Archivable, if you’ve seen the article, just prevents the instance from being saved. Imagine you have a build game with saving or something similar. If you hit save, the character will be in that snapshot. Really it’s mainly to prevent characters and players from being published (e.g. why Team Create sessions don’t push players to the production build as well), saved or cloned.
You can use it in Studio too. A plugin might create instances to be used and setting Archivable to false prevents those plugin materials from showing up in a live game.