Attacks Effecting Multiple Targets

Hello, I’m attempting to make a combat system for my game, but there’s one problem I’m currently having with it. Attacking a Single Target works, but upon making the character do a spin attack in a group of enemies only one enemy is effected resulting in the character getting pummeled to death. :joy: if someone could please shed some light on my problem I would much appreciate it I’ve Narrowed it down to being something within the following damage script

	
local Hit = Instance.new('Sound',hit.Parent.HumanoidRootPart)
Hit.SoundId = 'rbxassetid://636499038'
Hit.EmitterSize = 100 
Hit.Volume = .2 
local min = script.MinDMG.Value
local max = script.MaxDMG.Value
	local char = hit.Parent
	local hum = char:FindFirstChild("Humanoid")
	if hum and char	then 
		local Hurt  = Instance.new("Animation")
		Hurt.AnimationId = "rbxassetid://3369686028"
		local facemoveleftTrack = hum:LoadAnimation(Hurt):Play()
		hum:TakeDamage(math.random(min,max))
		Hit:Play()  
		local Maker = script.creator
		local SPD = script.Speed.Value
		Maker.Parent = hum 
		script.Disabled = true
		wait(SPD)
		game.Debris:AddItem(Maker,SPD + 0.5)
		script:Destroy()
	end
	if hum == nil then return end
end)

and I’m trying to accomplish this without the Player damaging themselves

2 Likes

You need to check if the character is the player’s character before you deal damage to the humanoid.

Thank you Fixed Attacking self, but still need help dealing damage to more than one person at a time if multiple were hit

	
local Hit = Instance.new('Sound',hit.Parent.HumanoidRootPart)
Hit.SoundId = 'rbxassetid://636499038'
Hit.EmitterSize = 100 
Hit.Volume = .2 
local min = script.MinDMG.Value
local max = script.MaxDMG.Value
	local char = hit.Parent
	local hum = char:FindFirstChild("Humanoid")
	if hum and char	then 
		local Hurt  = Instance.new("Animation")
		if script.creator.Value == char.Name then
			print("attempted to attack self")
		else 
			print(char.Name)
		Hurt.AnimationId = "rbxassetid://3369686028"
		local facemoveleftTrack = hum:LoadAnimation(Hurt):Play()
		hum:TakeDamage(math.random(min,max))
		Hit:Play()  
		local Maker = script.creator:Clone()
		local SPD = script.Speed.Value
		Maker.Parent = hum 
		script.Disabled = true
		wait(SPD)
		game.Debris:AddItem(Maker,SPD + 0.5)
			script:Destroy()
		end
	end
	if hum == nil then return end
end)

I won’t write a script for you. But have you tried adding a part cylindar part instance when the player hit? It act as a radius detection.

1 Like

By the looks of it seems like you using the touched event to detect the characters to damage, the touched event is not the best solution for this since it is not reliable. instead i recommend you use attachments and raycasting, if your not familiar with the aforementioned concepts then use this module : Raycast Hitbox 4.01: For all your melee needs!

I will look into this, thank you

I was attempting to use touch preferably for ease of use

I would use a table to store the NPCs/Players I hit and if they arn’t in the table deal damage and add them to the table, if they are in the table do nothing

basically something like this.

local HitTable = {}
Somthing.Touched:Connect(function(touched)
--check if they are player/npc
--check if they are in the table
--if not in table deal damage and add to table
--else ignore and dont do anything
end)

I’m going to try using your method

Having trouble implementing it into my script :cold_sweat:

The solution is here

His uses tools so it’s kinda confusing to me on how to implement it without using tools