The title says it all, when a player dies, how would i go about copying their avatar to the workspace and anchoring it?
Thanks in advance for the help
The title says it all, when a player dies, how would i go about copying their avatar to the workspace and anchoring it?
Thanks in advance for the help
I havent tested if it works but I dont think you have to make a code of 100 lines
try this:
game.Workspace.ChildRemoved:Connect(function(character)
local player = game.Players:GetPlayerFromCharacter(character)
if player then
local Main = character:WaitForChild("HumanoidRootPart")
local Humanoid = character:WaitForChild("Humanoid")
local Cloned = character:Clone()
Cloned.Parent = game.ReplicatedStorage
if Humanoid.Health < 0 then
local Position = character:WaitForChild("Head").Position
Cloned.Parent = game.Workspace
Cloned.HumanoidRootPart.Position = Position
for i,v in pairs(Cloned) do
if v:IsA("BasePart") then
v.Anchored = true
end
end
end
end
end)
game:GetService("Players").PlayerAdded:Connect(function(player)
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char.Humanoid
local fakeChar = char:Clone()
fakeChar.Parent = game.ReplicatedStorage
humanoid.Died:Connect(function()
fakeChar.Parent = game.Workspace
for i, v in pairs (fakeChar:GetChildren()) do
if v:IsA("BasePart") then
v.Anchored = true
end
end
end)
end)
Please tell me if there are any errors. Sorry for the messy formatting.
That’s strange. I doubt this would work but try to change game.ReplicatedStorage to game:GetService(“ReplicatedStorage”).
The character cannot be cloned because the Archivable property of characters is false, you need to set it to true before you clone the character.
https://developer.roblox.com/en-us/api-reference/property/Instance/Archivable