if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= "clone" then
if hit.Parent.Humanoid.Health - slice3Damage <=0 then
--clone the player, delete scripts, give infinite health, blood effect, play animation, destroy clone
--oh and rip off limb (hit) and set it flying
--clone player
local clone = hit.Parent:Clone()
clone.Humanoid.MaxHealth = math.huge
clone.Humanoid.Health = math.huge
clone.Humanoid.RequiresNeck = false
clone.Name = "clone"
clone.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
clone.HumanoidRootPart.Anchored = true
clone:PivotTo(hit.Parent:GetPivot())
local newHit
for i, child in pairs(clone:GetDescendants()) do
if child.Name == hit.Name then
newHit = child
break
end
end
hit.Parent:Destroy()
This is only part of a script I wrote, where the area seems to be centered.
Essentially what I do is look for a humanoid, then check if the humanoid health minus the damage will give us a number less than or equal to zero (it will kill the player). If so, trigger a unique death effect. To do this, I clone the player, set their health to infinite (so they can’t be killed during the death animation), move them to the players location, then get newHit for later. Then, I destroy the original player.
This works perfectly for dummies. Haven’t had a single issue.
But when I make a test server with two players, for some strange reason, it always errors on this, and says “attempt to index nil with :FindFirstChild()” or “attempt to index nil with .Humanoid” on lines 2 and 8 respectively.
Why???