Custom character collapsing and not being copied properly when setting it to a player's character

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to make a custom character that a player can change into.
  2. What is the issue? Include screenshots / videos if possible!
    Whenever I try to copy the custom character (in replicatedstorage) to a player’s character, it collapses and the legs + arms are deleted. I used the following code:
function setMonsterPlayerCharacter()
	for i, v in pairs(game.Players[game.Workspace.MonsterName.Value].Character:GetChildren()) do
		v:Destroy()
	end
	for i, v in pairs(game.ReplicatedStorage.StarterCharacter:GetChildren()) do
		local c = v:Clone()
		c.Parent = game.Players[game.Workspace.MonsterName.Value].Character
	end
	task.wait(0.01)
	game.Players[game.Workspace.MonsterName.Value].Character.Humanoid.WalkSpeed = 8
end
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I looked for solutions on the developer hub and found/tried one (setting the player.Character value directly) but it didn’t work.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Your issue is that you are deleting the entire character (all instances parented to the player’s character) and cloning new parts and putting them into the character. These parts you are copying do not automatically form into a new character. I think you should try a new approach - maybe try having a remote-controlled monster and put the player in a hidden location where they cannot be seen. There are ways to change the character itself that you can research as well.

function setPlayerCharacter()
for i, v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
v:Destroy()
end
for i, v in pairs(game.ReplicatedStorage.StarterCharacter:GetChildren()) do
local c = v:Clone()
c.Parent = game.Players.LocalPlayer.Character
end
task.wait(0.01)
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
end

function setPlayerCamera()
local cam = game.Workspace.FindPlayerCamera.Camera
cam.CameraType = “Fixed”
cam.CFrame = game.Workspace.FindPlayerCamera.CFrame
cam.CFrame = cam.CFrame - cam.CFrame.LookVector * 10
cam.CFrame = cam.CFrame + cam.CFrame.RightVector * -5
end

function resetCamera()
game.Workspace.FindPlayerCamera.Camera.CameraType = “Custom”
end

function playSound()
local s = Instance.new(“Sound”)
s.SoundId = “rbxassetid://1142136398”
s.Volume = 1
s.Parent = workspace.FindPlayerCamera
s.PlayOnRemove = true
s:Remove()
end

game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function()
setPlayerCharacter()
resetCamera()
playSound()
end)

function onMonsterDied()
game.ReplicatedStorage.Events.MonsterDied:FireServer()
end

function onVictory()
game.ReplicatedStorage.Events.Victory:FireServer()
end

game.Workspace.Player.Humanoid.Died:Connect(function()
onVictory()
end)

function onMonsterHit(hit)
local char = hit.Parent
if char ~= nil then
if not char:IsA(“Hat”) and not char:IsA(“BasePart”) then
onMonsterDied()
end
end
end

function onPlayerHit(hit)
local char = hit.Parent
if char ~= nil then
if not char:IsA(“Hat”) and not char:IsA(“BasePart”) then
char.Humanoid:TakeDamage(5)
end
end
end

game.Workspace.Player.Touched:Connect(function(hit)
onPlayerHit(hit)
end)

game.Workspace.Monster.Touched:Connect(function(hit)
onMonsterHit(hit)
end)

function onMonsterSpawned()
game.ReplicatedStorage.Events.MonsterSpawned:FireServer()
end

function onGameStart()
game.ReplicatedStorage.Events.GameStart:FireServer()
end

function onPlayerDied()
game.ReplicatedStorage.Events.PlayerDied:FireServer()
end

function onGameOver()
game.ReplicatedStorage.Events.GameOver:FireServer()
end

function onPlayerVictory()
game.ReplicatedStorage.Events.PlayerVictory:FireServer()
end

function onPlayerReady()
game.ReplicatedStorage.Events.PlayerReady:FireServer()
end

function onPlayerCantMove()
game.ReplicatedStorage.Events.PlayerCantMove:FireServer()
end

function onPlayerCanMove()
game.ReplicatedStorage.Events.PlayerCanMove:FireServer()
end

function onPlayerGaveUp()
game.ReplicatedStorage.Events.PlayerGaveUp:FireServer()
end

function onMonsterGaveUp()
game.ReplicatedStorage.Events.MonsterGaveUp:FireServer()
end

function onPlayerTeleported()
game.ReplicatedStorage.Events.PlayerTeleported:FireServer()
end

function onPlayerCanTeleport()
game.ReplicatedStorage.Events.PlayerCanTeleport:FireServer()
end

function onPlayerCantTeleport()
game.ReplicatedStorage.Events.PlayerCantTeleport:FireServer()
end

function onPlayerTeleport()
game.ReplicatedStorage.Events.PlayerTeleport:FireServer()
end

function onPlayerLeft()
game.ReplicatedStorage.Events.PlayerLeft:FireServer()
end

function onPlayerJoined()
game.ReplicatedStorage.Events.PlayerJoined:FireServer()
end

function onPlayerIsIt()
game.ReplicatedStorage.Events.Player

Nevermind, figured it out myself, for some reason only the original version of the character works as a player’s character, if I clone the character it doesn’t work but if I use the original one in replicatedstorage it works, pretty weird but I can use it since only one player in my game is going to have this character at a time

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.