This works for dummies but not players, and for a very strange reason...?

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???

1 Like

Are you sure the player’s character is Archivable?

You also need to check if the parent exists.

if hit.Parent then

end

this

I haven’t read a lot but please make sure to set it archivable, roblox characters arent archivable by default if i remember

The instance method :Clone() can only be called on instances which have their Archivable property enabled, you can see this in clone’s documentation.

https://developer.roblox.com/en-us/api-reference/function/Instance/Clone

Clone creates a copy of an object and all of its descendants, ignoring all objects that are not Archivable . The copy of the root object is returned by this function and its Parent is set to nil.

i cannot believe i forgot this
i have seen you everywhere
you are my hero
god bless my good man