Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does .Touched rapidly damage humanoids?

this is my script

local Mouse = game.Players.LocalPlayer:GetMouse()

local animation = script.Parent:WaitForChild("Idle")
local track = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(animation)
track.Looped = true
--------------------
local Remote = game.ReplicatedStorage.Box
--------------------
local punch = script.Parent:WaitForChild("Punch")
local track2 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(punch)
cooldown = false
local Char = game.Players.LocalPlayer.Character
--------------------
local left = script.Parent:WaitForChild("Left")
local track3 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(left)
local punched1 = false
debounce = false

script.Parent.Equipped:Connect(function(Mouse)
	track:Play()
end)
script.Parent.Unequipped:Connect(function()
	track:Stop()
end)
Mouse.Button1Down:connect(function()
	if cooldown == false and punched1 == false then
		 track2:Play()
		--------------------
		
				
			Char["Right Arm"].Touched:Connect(function(Hit)
				if Hit.Parent.Humanoid and debounce == false then
			Hit.Parent.Humanoid:TakeDamage(5)
			
		punched1 = false
		cooldown = true
		debounce = true
		wait(0.5) 
		cooldown = false
		debounce = false
		end		
		end)
		

			
		----------------
		

	end -- if
	
end)

Why when I click to punch whatever my right hand touches gets damaged and it doesnt stop? I want it to only damage a player once until i hit them again but its like a burst damage that keeps damaging anything that touches it

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.