Player dropping part on death not working after player morphs

Using a morph gui with a separate script located inside of StarterCharacterScripts.
Program is designed for player to drop part when they die. All of this is working fine, EXCEPT:
When the player morphs, part does not drop.

Thanks in advance!

--Morph Script
game.ReplicatedStorage.Morphing.OnServerEvent:connect(function(player, Type, Args)
	if Type == "Morph" then
		local morph = game.ReplicatedStorage.Morphs:WaitForChild(Args):Clone()
		morph.Name = player.Name
		player.Character = morph
		morph.Parent = workspace
		local playername = player.Name
		print("Successfully morphed "..playername.."!")
	else
		local playername = player.Name
		print("Error while morphing "..playername.."!")
	spawn(function()
		local area = workspace._Spawn
		player.Character.HumanoidRootPart.CFrame = CFrame.new(area.Position.X + math.random(area.Size.X) - area.Size.X*1/2, area.Position.Y+math.random(1,3), area.Position.Z + math.random(area.Size.Z) - area.Size.Z*1/2)
	end)
	end
end)

local Players = game:GetService("Players")
game.Players.PlayerAdded:connect(function(player)
	game:GetService('RunService').Stepped:wait()
	player.CharacterAdded:connect(function(Character)
		player.PlayerGui:WaitForChild("Morph").Enabled = true
	end)
end)
--Part Drop Script
local char = script.Parent
local hum = char.Humanoid
local players = game.Players
local corpse = game.ReplicatedStorage.Folder.Part
hum.Died:Connect(function()
	local player = players:GetPlayerFromCharacter(char)
	corpse.CFrame = char.HumanoidRootPart.CFrame
	corpse:Clone().Parent = game.Workspace
end)
1 Like

Before cloning the player’s character, set the model’s archivable property to true.

1 Like

Thanks for the reply, but I tried that and it didn’t work. Any other ideas?

1 Like

Clone the model directly from where it came from.

Example: If it’s in server storage on morphing, do this:

local serverStorage = game:GetService("ServerStorage")
local folderWithCreatures = serverStorage:WaitForChild("Creatures", 1)

local function returnCreatureWithName(name)
local model = folderWithCreatures:WaitForChild(name, 1)

if model then
print(name.." Has been found in folder.")
return model
else
print(name.." Not found in folder.")
end
end

humanoid.Died:Connect(function()
local characterName = character.Name
local model = returnCreatureWithName(characterName):Clone()

if model then
model.Parent = workspace
model.HumanoidRootPart.CFrame = character.Head.CFrame * CFrame.new(0, 10, 0)
character:Destroy() -- Destroy the character. In the humanoid, turn BreakJointsOnDeath off in the humanoid.
end
end)
1 Like

Unfortunately your code didn’t work bc an error on line 9 with WaitForChild. However, your help made me able to find the solution. I needed to put the part drop script into the morph model instead of StarterCharacterScripts. Thanks again for the help!

1 Like