When the other Humanoid dies, mine dies too

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

i want it so my humanoid dont die, i believe its the welding

  1. What is the issue? Include screenshots / videos if possible!

the problem starts at "if Ability == “AB2”.

local Remotes = script.Parent.Remotes
local Animations = script.Parent.Animations
local Sounds = script.Parent.Sounds

local RS = game:GetService("ReplicatedStorage")

local Modules = RS.Modules

local AnimModule = require(Modules.AnimationPlayer)
local SoundModule = require(Modules.SoundPlayer)
local HitboxModule = require(Modules.Hitbox)
local DamageModule = require(Modules.Damage)

local LMBCount = 1

Remotes.CombatEvent.OnServerEvent:Connect(function(plr, Ability)
	
	local char = plr.Character
	local hum = char:FindFirstChild("Humanoid")
	local HRP = char:FindFirstChild("HumanoidRootPart")
	
	if Ability == "LMB" then
		
		SoundModule:Play(HRP, Sounds.LMB, 1)
		
		local Hitbox = HitboxModule.new()
		
		Hitbox.CFrame = HRP.CFrame
		
		Hitbox.Size = Vector3.new(6, 3, 7)
		
		Hitbox.Offset = CFrame.new(0, 0, -4)
		
		Hitbox.onTouch = function(TargetHum)
			
			if TargetHum ~= hum then
				
				SoundModule:Play(TargetHum.Parent:FindFirstChild("HumanoidRootPart"), Sounds.Hit, 1)
				DamageModule:Damage(TargetHum, hum, "Normal", 10)
				
			end
			
		end
		
		task.spawn(function()
			
			for i = 1, 5 do
				
				Hitbox:Start()
				task.wait(0.025)
				Hitbox:Stop()
				Hitbox.CFrame = HRP.CFrame
				task.wait(0.001)
				
			end
			
		end)
		
		Remotes.CombatEvent:FireClient(plr, "LMB")
		
		task.spawn(function()
			
			if LMBCount == 1 then

				AnimModule:Animation(hum, Animations.Lmb1):Play(0)
				AnimModule:Animation(hum, Animations.Lmb2):Stop(0)

				LMBCount += 1

			elseif LMBCount == 2 then

				AnimModule:Animation(hum, Animations.Lmb2):Play(0)
				AnimModule:Animation(hum, Animations.Lmb1):Stop(0)

				LMBCount = 1

			end
			
		end)
		
	end
	
	if Ability == "AB2" then
		
		task.spawn(function()
			
			local Anim
			
			Anim = AnimModule:Animation(hum, Animations.AB2)
			
			
			
			Anim:Play(0)
			
			Anim:GetMarkerReachedSignal("Grab"):Connect(function()
				
				local Hitbox = HitboxModule.new()
				
				Hitbox.CFrame = HRP.CFrame
				
				Hitbox.Size = Vector3.new(12, 3, 12)
				
				Hitbox.onTouch = function(TargetHum)

					if TargetHum ~= hum and (HRP.Position - TargetHum.Parent:FindFirstChild("HumanoidRootPart").Position).Magnitude <= 5 then
						
						local GrabAnim, GrabbedAnim

						Anim:Stop(0)

						GrabAnim = AnimModule:Animation(hum, Animations.AB2Grab)

						GrabbedAnim = AnimModule:Animation(TargetHum, Animations.AB2Grabbed)

						local Weld = Instance.new("Motor6D")

						Weld.Parent = HRP

						Weld.Part1 = HRP
						Weld.Part0 = TargetHum.Parent:FindFirstChild("HumanoidRootPart")

						Weld.C0 = CFrame.new(0.046, -0.05, -3.046) * CFrame.Angles(math.rad(0), math.rad(180), math.rad(0))
						
						--HRP.Anchored = true
						
						--TargetHum.Parent:FindFirstChild("HumanoidRootPart").Anchored = true

						GrabbedAnim:Play(0)

						GrabAnim:Play(0)

						DamageModule:Damage(TargetHum, hum, "Normal", 10)

						GrabAnim:GetMarkerReachedSignal("Attack"):Connect(function()

							DamageModule:Damage(TargetHum, hum, "Normal", 4)

						end)

						GrabAnim:GetMarkerReachedSignal("End"):Connect(function()

							DamageModule:Damage(TargetHum, hum, "Normal", 7)

							Weld:Destroy()

						end)
						
					elseif TargetHum ~= hum then

						DamageModule:Damage(TargetHum, hum, "Normal", 7.5)
						
					end

				end
				
				Hitbox:Start()
				task.wait(0.025)
				Hitbox:Stop()
				
			end)
			
		end)
		
	end
	
end)

Ideally, you would remove the Weld before the damage is applied. You just need to check if the damage will be enough to kill.
On the other hand, this should solve the problem if you disable the Humanoid’s BreakJointsOnDeath property.

2 Likes

okay, ill try.

btw, do you know why roblox does that when both of the other user and urself die together while welded?

Yes. When you create a Weld between two objects, the network property becomes one. Depending on who the network property of the two humanoids is with, this can happen. If the humanoid that does not have the network property dies, the humanoid that has the network property also dies.

Have you tried printing TargetHum and hum? It could be that the two variables have some difference which the if-statement can’t detect.

then could i just add the weld property to the other user instead of urself?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.