So I’m trying to make a cool death script that can duplicate the dead body. I’m going to add more things, but right now this is my only problem. I’ve written this code here:
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
humanoid.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Dead then
local body = character:Clone()
body.Torso.Position = Vector3.new(character.Torso.Position)
body.Parent = workspace
end
end)
But then it throws this error:
LocalScript:6: attempt to index nil with 'Torso'
How can I fix this?