This is in a local script

--//Variables
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local rightArm = character:WaitForChild("RightLowerArm")
local userInputService = game:GetService("UserInputService")

--//Debounces
local debounce = false
local debounce2 = false

--//Animation
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=2637322749"
local loadAnimation = humanoid:LoadAnimation(animation)

--//InputBegan
userInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Q and not debounce then
		debounce = true
		loadAnimation:Play()
		wait(1)
		debounce = false
	end
end)

--//TouchedEvent
rightArm.Touched:Connect(function(hit)
	if debounce and hit.Parent:FindFirstChild("Humanoid") and not debounce2 then
		debounce2 = true
		hit.Parent.Humanoid:TakeDamage(15)
		wait(1)
		debounce2 = false
	end
end)

What i'm trying to do is make a punching script that can hit multiple players at once but using the touched event only allows me to hit one at a time as you can see here,

https://gyazo.com/ed58afe2cfca5c3e808307c5669e25a1

The arm is touching both dummies but it randomly chooses the closest one.

4 comments

0

Your debounce is what is preventing it from going through multiple layers.

0

The first debounce is for the skill's cooldown and the second is so that each punch only does damage once

0

Try placing the touched event inside UI service function

0

Ehh it didn't work.