Good afternoon,
I'm trying to clone the local player's character into a model inside ReplicatedStorage named "NPC." I can't seem to figure out what's wrong with it and the last lines following the function work perfectly. I am welcome to any ideas, suggestions and recommendations. Thank you, for your time.
local pl = game.Players.LocalPlayer if pl and pl.Character then local c = pl.Character c.Archivable = true local duplicate = c:clone() duplicate.Parent = game.ReplicatedStorage.NPC end game.Players.LocalPlayer.PlayerGui:WaitForChild('PlayerAppear').Enabled = true game.Players.LocalPlayer.PlayerGui:WaitForChild('PlayerAppear'):WaitForChild('LocalScript').Disabled = false
Your problem here is that you're trying to clone and move something from the client. That is not possible. What you might want to consider is creating a RemoteEvent in Workspace and firing it to do the cloning work. So basically keep this in the LocalScript:
local pl = game.Players.LocalPlayer if pl and pl.Character then local c = pl.Character workspace.RemoteEvent:FireServer(c) -- You can change "RemoteEvent" to whatever your RemoteEvent is called. c.Archivable = true local duplicate = c:clone() duplicate.Parent = game.ReplicatedStorage.NPC end game.Players.LocalPlayer.PlayerGui:WaitForChild('PlayerAppear').Enabled = true game.Players.LocalPlayer.PlayerGui:WaitForChild('PlayerAppear'):WaitForChild('LocalScript').Disabled = false
Now put this inside a ServerScript in Workspace:
workspace.RemoteEvent.OnServerEvent:connect(function(c) c.Archivable = true local duplicate = c:clone() duplicate.Parent = game.ReplicatedStorage.NPC end)
Then everything should work as expected.
EDIT:
Since I'm pretty sure you cannot simply clone a player character try this inside the ServerScript:
workspace.RemoteEvent.OnServerEvent:connect(function(plr, c) local duplicate = Instance.new("Model") duplicate.Name = c.Name for _, v in pairs(c:GetChildren()) do v:Clone().Parent = duplicate end duplicate.Parent = game.ReplicatedStorage.NPC end)