Death Animation?

so i tried to make something like, when you die , your parts will disappear and soul will come one and shatter. i tried this script:

game.Players.PlayerAdded:connect(function(Player)
 Player.CharacterAdded:connect(function()
  Player.Character.Humanoid.Died:connect(function()
	local char = Player.Character
	local d = game.ReplicatedStorage.Death.Soull:Clone()
	local c = game.ReplicatedStorage.Death.HalfHeart:Clone()
	d:SetPrimaryPartCFrame(CFrame.new(char.HumanoidRootPart.Position.X,char.HumanoidRootPart.Position.Y,char.HumanoidRootPart.Position.Z))
	c:SetPrimaryPartCFrame(CFrame.new(d.PrimaryPart.Position.X,d.PrimaryPart.Position.Y,d.PrimaryPart.Position.Z))
   for _,Part in next, Player.Character:children() do
    if Part:IsA('BasePart') or Part:IsA('Accessory') or Part:IsA('Model') or Part:IsA('Tool') or Part:IsA('Hat') then
     Part:Destroy()
    end
	d.Parent = workspace
	wait(2)
	d:Destroy()
	c.Parent = workspace
	wait(2)
	c:Destroy()
   end
  end)
 end)
end)

the problem is, that the soul’s position is weird and it changes everytime and the human parts won’t disappear, it also gives error

what i mean by weird:
https://gyazo.com/41605968fd9d5daf274dce11648c418a

i want it to face same position on death and make parts disappear

Try this;

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function()
Player.Character.Humanoid.Died:connect(function()
local char = Player.Character
local d = game.ReplicatedStorage.Death.Soull:Clone()
local c = game.ReplicatedStorage.Death.HalfHeart:Clone()
d:SetPrimaryPartCFrame(CFrame.new(char.HumanoidRootPart.Position.X,char.HumanoidRootPart.Position.Y,char.HumanoidRootPart.Position.Z))
c:SetPrimaryPartCFrame(CFrame.new(d.PrimaryPart.Position.X,d.PrimaryPart.Position.Y,d.PrimaryPart.Position.Z))
for _,Part in next, Player.Character:children() do
  if Part:IsA('BasePart') or Part:IsA('Accessory') or Part:IsA('Model') or Part:IsA('Tool') or Part:IsA('Hat') then
    Part.Transparency = 1
  end
  d.Parent = workspace
  wait(2)
  d:Destroy()
  c.Parent = workspace
  wait(2)
  c:Destroy()
end
end)
end)
end)

You are trying to destroy locked parts, that can’t be edited by a script is what the screenshoted error is saying, so just change their transparency to 1.

Also, unlock Soull in replicated storage, there should be a value that says “Locked” or you can put it in workspace and use the lock and unlock tool to unlock it, what the error is actually saying is that it is locked.

1 Like

it was unlocked already, and the new script still gives same issue

Try this;

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function()
Player.Character.Humanoid.Died:connect(function()
local char = Player.Character
d:SetPrimaryPartCFrame(CFrame.new(char.HumanoidRootPart.Position.X,char.HumanoidRootPart.Position.Y,char.HumanoidRootPart.Position.Z))
c:SetPrimaryPartCFrame(CFrame.new(d.PrimaryPart.Position.X,d.PrimaryPart.Position.Y,d.PrimaryPart.Position.Z))
for _,Part in next, Player.Character:children() do
  if Part:IsA('BasePart') or Part:IsA('Accessory') or Part:IsA('Model') or Part:IsA('Tool') or Part:IsA('Hat') then
    Part.Transparency = 1
  end
local d = game.ReplicatedStorage.Death.Soull:Clone()
  d.Parent = workspace
  wait(2)
  d:Destroy()
local c = game.ReplicatedStorage.Death.HalfHeart:Clone()
  c.Parent = workspace
  wait(2)
  c:Destroy()
end
end)
end)
end)

it gives an error that d is a nil value now

I think I just need to add a wait statement here;

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function()
Player.Character.Humanoid.Died:connect(function()
local char = Player.Character
d:SetPrimaryPartCFrame(CFrame.new(char.HumanoidRootPart.Position.X,char.HumanoidRootPart.Position.Y,char.HumanoidRootPart.Position.Z))
c:SetPrimaryPartCFrame(CFrame.new(d.PrimaryPart.Position.X,d.PrimaryPart.Position.Y,d.PrimaryPart.Position.Z))
for _,Part in next, Player.Character:children() do
  if Part:IsA('BasePart') or Part:IsA('Accessory') or Part:IsA('Model') or Part:IsA('Tool') or Part:IsA('Hat') then
    Part.Transparency = 1
  end
  local d = game.ReplicatedStorage.Death.Soull:Clone()
  wait()
  d.Parent = workspace
  wait(2)
  d:Destroy()
  local c = game.ReplicatedStorage.Death.HalfHeart:Clone()
  wait()
  c.Parent = workspace
  wait(2)
  c:Destroy()
end
end)
end)
end)

If this does not work, could you send a file of the soull and the halfheart?

ani.rbxm (86.4 KB)

Fixed it for you, instead of models I ungrouped them, here is the script,

game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function()
Player.Character.Humanoid.Died:Connect(function()
local char = Player.Character
  wait()
  local d = game.ReplicatedStorage.Death.Soull:Clone()
  d.CFrame = CFrame.new(char.HumanoidRootPart.Position.X,char.HumanoidRootPart.Position.Y,char.HumanoidRootPart.Position.Z)
  d.Parent = workspace
  wait(2)
  d:Destroy()
  wait()
  local c = game.ReplicatedStorage.Death.HalfHeart:Clone()
  c.CFrame = CFrame.new(d.CFrame.Position.X,d.CFrame.Position.Y,d.CFrame.Position.Z)
  c.Parent = workspace
  wait(2)
  c:Destroy()
end)
end)
end)

Here is the file of the whole thing

DevForum_Help.rbxl (26.9 KB)

but humanoid parts won’t disappear

oh there i found a way:

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function()
Player.Character.Humanoid.Died:connect(function()
local char = Player.Character
local ds = game.ReplicatedStorage.Death.Soull
local cs = game.ReplicatedStorage.Death.HalfHeart
ds:SetPrimaryPartCFrame(CFrame.new(char.HumanoidRootPart.Position.X,char.HumanoidRootPart.Position.Y,char.HumanoidRootPart.Position.Z))
cs:SetPrimaryPartCFrame(CFrame.new(ds.PrimaryPart.Position.X,ds.PrimaryPart.Position.Y,ds.PrimaryPart.Position.Z))
for _,Part in next, Player.Character:children() do
  if Part:IsA('BasePart') or Part:IsA('Accessory') or Part:IsA('Model') or Part:IsA('Tool') or Part:IsA('Hat') then
    Part:Destroy()
  end
end
  local d = game.ReplicatedStorage.Death.Soull:Clone()
  wait()
  d.Parent = workspace
  wait(2)
  d:Destroy()
  local c = game.ReplicatedStorage.Death.HalfHeart:Clone()
  wait()
  c.Parent = workspace
  wait(2)
  c:Destroy()
end)
end)
end)

idk if it work on every player that will die

1 Like

but the souls still not facing the right direction… how i fix that?