Character dies spontaneously

I’m trying to make like a moveset for a combat system.

The problem though is that whenever I use animation events to damage the target character, the person who damages the target is dying at the end.

They don’t get damaged on hit 2, but die completely at the end.

This makes no sense to me as I have an unreliable remote event on the server that damages the target, and when I print the target’s character, it never prints the actor of the event(attacker).

Example code on server:

	Unreliables.ToServer.OnServerEvent:Connect(function(player,signal,movesetIndex)
		local character = player.Character or player.CharacterAdded:Wait()
		local root = character.HumanoidRootPart
		local humanoid = character.Humanoid
		
		local weld = root:FindFirstChildWhichIsA("WeldConstraint")
		local target = weld.Part1.Parent

		local hitString = string.gsub(signal,"Hit","")
		local hitNumber = tonumber(hitString)
		
		if hitNumber and hitNumber ~= "" and typeof(hitNumber) == "number" then
			print(target.Parent)
			local damage = Moveset[movesetIndex][3][hitNumber]
			target.Humanoid:TakeDamage(damage)
			return
		elseif signal == "CFrame" then
			target.HumanoidRootPart.CFrame = target.HumanoidRootPart.Parent["Torso"].CFrame
			weld:Destroy()
		end
	end)

Unreliables.ToServer.OnServerEvent:Connect(function(player, signal, movesetIndex)
	local character = player.Character or player.CharacterAdded:Wait()
	local root = character.HumanoidRootPart
	local humanoid = character.Humanoid
	
	local weld = root:FindFirstChildWhichIsA("WeldConstraint")
	local target = weld and weld.Part1 and weld.Part1.Parent
	
	-- Check if the target is an enemy and not the player's own character
	if target and target ~= character then
		local targetHumanoid = target:FindFirstChildOfClass("Humanoid")
		if targetHumanoid then
			local hitString = string.gsub(signal, "Hit", "")
			local hitNumber = tonumber(hitString)
			
			if hitNumber and hitNumber ~= "" and typeof(hitNumber) == "number" then
				print(target.Parent)
				local damage = Moveset[movesetIndex][3][hitNumber]
				targetHumanoid:TakeDamage(damage)
				return
			elseif signal == "CFrame" then
				target.HumanoidRootPart.CFrame = target.HumanoidRootPart.Parent["Torso"].CFrame
				weld:Destroy()
			end
		end
	else
		warn("Invalid target or target is the player themselves.")
	end
end)

check the output now

1 Like

sadly it didn’t work and I made the issue of saying target.Parent when the target is the character, its still the rig only though.

1 Like

I’d also like to mention it happens sometimes and other times it doesnt, very strange.

Yeah that’s strange. Maybe the way the weld is being used is the issue

Unreliables.ToServer.OnServerEvent:Connect(function(player, signal, movesetIndex)
	local character = player.Character or player.CharacterAdded:Wait()
	local root = character:FindFirstChild("HumanoidRootPart")
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	
	if not root or not humanoid then
		warn("Player character missing HumanoidRootPart or Humanoid.")
		return
	end
	
	local weld = root:FindFirstChildWhichIsA("WeldConstraint")
	local target = weld and weld.Part1 and weld.Part1.Parent
	
	-- Check if the target is an enemy and not the player's own character
	if target and target ~= character then
		local targetHumanoid = target:FindFirstChildOfClass("Humanoid")
		if targetHumanoid then
			local hitString = string.gsub(signal, "Hit", "")
			local hitNumber = tonumber(hitString)
			
			if hitNumber and hitNumber ~= "" and typeof(hitNumber) == "number" then
				print(target.Parent)
				local damage = Moveset[movesetIndex][3][hitNumber]
				targetHumanoid:TakeDamage(damage)
				return
			elseif signal == "CFrame" then
				if target:FindFirstChild("HumanoidRootPart") then
					target.HumanoidRootPart.CFrame = target.HumanoidRootPart.Parent["Torso"].CFrame
					weld:Destroy()
				else
					warn("Target missing HumanoidRootPart.")
				end
			end
		end
	else
		warn("Invalid target or target is the player themselves.")
	end
end)

1 Like

Nah, I just died and nothing in the output.

1 Like

k so its not damaging anymore, but I can’t make the CFrame signal event happen in a timely manner because when its supposed to happen, I think its already to late when the message is received on the server by approximately .25 seconds.