Enemy health bars disappearing after being hit?


i got this pretty long R6 module script from a youtube video for this game im trying to make, but whenever i hit enemies with the bat weapon, their health bar disappears. is this issue happening because of something inside it, or could it be how im using the ragdoll module in my damage script (i can post it if anyone thinks its necessary)? how do i fix it? the issue wasn’t happening before i added the ragdoll and it was just knockback.

module script:

function Module:SetupRagdoll(Character:Model,RagdollOnDeath:boolean)
	local PhysicsService = game:GetService("PhysicsService")
	local StarterPlayer = game:GetService("StarterPlayer")
	local Runservice = game:GetService("RunService")
	
	local BodyPart = {}
	local Information = {
		IgnoreParts = {"HumanoidRootPart","LowerTorso","UpperTorso","Torso"},
		CollisionPartOffset = {["R6"] = 1.8,["R15"] = 2,["Rthro"] = 2.25},
		IsRagdolled = false,
		Run = nil,
	}
	
	local function CreateCollisionPart(Part:Part,Offset:number)
		local CollideFolder = Character:FindFirstChild("RagdollCollision")
		if not CollideFolder then
			CollideFolder = Instance.new("Folder",Character)
			CollideFolder.Name = "RagdollCollision"
		end
		
		local Collider = Instance.new("Part",Part)
		Collider.Size = Part.Size/tonumber(Offset) or 1
		Collider.Transparency = 1
		Collider.CanQuery = false
		Collider.CanTouch = false
		Collider.Massless = true
		Collider.CFrame = Part.CFrame
		Collider.Parent = CollideFolder
		
		if not PhysicsService:IsCollisionGroupRegistered("RagdollCollision") then
			PhysicsService:RegisterCollisionGroup("RagdollCollision")
		end

		Part.CollisionGroup = "RagdollCollision"
		PhysicsService:CollisionGroupSetCollidable("Default", "RagdollCollision", false)
		
		local Weld = Instance.new("WeldConstraint",Collider)
		Weld.Part0 = Collider
		Weld.Part1 = Part
	end
		
	if Character == nil then
		error("Argument 1 missing")
	end
	
	local Humanoid = Character:FindFirstChildOfClass("Humanoid")
	if not Humanoid then
		error("Character 'Humanoid' missing")
	end
	
	for _,Object in pairs(Character:GetChildren()) do
		if Object:IsA("BasePart") then
			table.insert(BodyPart,Object)
		end
	end
	
	local temp = {}
	local Ragdolling = {
		Ragdoll = function(TimeLength:number)
			if Information.IsRagdolled == false then
				local Boolean,Return = pcall(function()
					Information.IsRagdolled = true
					for _, Object in pairs(Character:GetDescendants()) do
						if Object:IsA("Motor6D") then
							local Attachment0, Attachment1 = Instance.new("Attachment"), Instance.new("Attachment")
							Attachment0.CFrame = Object.C0
							Attachment1.CFrame = Object.C1
							Attachment0.Parent = Object.Part0
							Attachment1.Parent = Object.Part1
							Attachment0.Name = string.format("%s:%s","Ragdoll",Attachment0.ClassName)
							Attachment1.Name = string.format("%s:%s","Ragdoll",Attachment1.ClassName)
							
							local BallSocketConstraint = Instance.new("BallSocketConstraint")
							BallSocketConstraint.Attachment0 = Attachment0
							BallSocketConstraint.Attachment1 = Attachment1
							BallSocketConstraint.Parent = Object.Part0
							BallSocketConstraint.Name = string.format("%s:%s","Ragdoll",BallSocketConstraint.ClassName)
							
							if not table.find(Information.IgnoreParts,Object.Part1.Name) then
								CreateCollisionPart(Object.Part1,Information.CollisionPartOffset[Humanoid.RigType.Name])
							end
							
							Object.Enabled = false
						end
					end
					
					Information.Run = Runservice.Heartbeat:Connect(function()
						if Information.IsRagdolled == false then
							Information.Run:Disconnect()
						end
						
						Humanoid.PlatformStand = Information.IsRagdolled
						if StarterPlayer.CharacterUseJumpPower then
							if Information.IsRagdolled then
								Humanoid.JumpPower = 0
							else
								Humanoid.JumpPower = StarterPlayer.CharacterJumpPower
							end
						else
							if Information.IsRagdolled then
								Humanoid.JumpHeight = 0
							else
								Humanoid.JumpHeight = StarterPlayer.CharacterJumpHeight
							end
						end
					end)
					
					if typeof(TimeLength) == "number" and TimeLength > 0 then
						task.delay(TimeLength,function()
							temp.Unragdoll()
						end)
					end
				end)
				
				if not Boolean then
					error(Return)
				end
			end
		end;
		
		Unragdoll = function()
			if Information.IsRagdolled == true and Humanoid.Health > 0 then
				local Boolean,Return = pcall(function()
					Information.IsRagdolled = false
					local CollideFolder = Character:FindFirstChild("RagdollCollision")
					if CollideFolder then
						CollideFolder:ClearAllChildren()
					end

					for _,Object in pairs(Character:GetDescendants()) do
						if Object:IsA('Motor6D') then
							Object.Enabled = true
						end

						if Object.Name == string.format("%s:%s","Ragdoll",Object.ClassName) then
							Object:Destroy()
						end
					end
				end)
				
				if not Boolean then
					error(Return)
				end
			end
		end;
	}
	
	if RagdollOnDeath == true then
		Humanoid.BreakJointsOnDeath = false
		Humanoid.Died:Connect(function()
			Ragdolling.Ragdoll()
		end)
	end
	
	temp = Ragdolling
	return Ragdolling
end

return Module

If you break or delete the head weld a Robloxian dies.
What happens if you uncheck the RequiresNeck property of the Humanoid?

Unsure, but

I believe it might have something to do with not setting PlatformStand back to false
UNSURE, is there anything in any debugging window that might help shed light on what’s happening?

nothing shows up in the output window, even when/after i hit an enemy

Have you tried disabling healing of the enemy?

i just tried it, and it didnt work

i disabled RequiresNeck on the dummies’ humanoids and nothing changed

Bro, I believe this is a studio bug that is showing up again.

Except they said it has been resolved, 10 days ago.

not sure if this helps/changes anything, but i found that health bars disappear whenever enemies are ragdolled at all, not just when they take damage from the bat

Check all the places you directly manipulate the humanoid instance, and make sure they’re all operating correctly.

looked through the module and the only parts that directly change the humanoid is
-line 155: Humanoid.PlatformStand = Information.IsRagdolled
-line 158, 160, 164, 166: change jump power and jump height when the ragdoll starts/ends
-line 212: Humanoid.BreakJointsOnDeath = false
i dont think any of these would effect the health showing up

Well it seems like the issue is not resolved for you. If I was you. I would send a bug report.

Just my two cents in the matter.

the issue in that video isnt even the same thing though, i can see my own health, i just cant see enemies’ health bars

1 Like