In my game I am trying to make dead players’ characters stay laying around by cloning their dead characters before they respawn. Problem is when I go to get the character model using script.Parent it returns a nil value. I’m not sure how it is even possible for a script to not have a parent.
The following code executes as a character script whenever the humanoid dies.
local Character = script.Parent
local Player = game:GetService("Players"):FindFirstChild(Character.Name)
wait(game:GetService("Players").RespawnTime)
local CharClone = script.Parent:Clone()
CharClone.Name = "Corpse"
CharClone.Parent = game.Workspace
Player:LoadCharacter()