Only have Touched Event work inside Tool.Activated (or Alternative solutions?)

I’m making a sword but don’t know how to have the player deal damage.
I want the sword to only deal damage if the player activates the tool, but I don’t know how.

Tool.Activated:Connect(function()
	script.Parent:WaitForChild("Hitbox").Touched:Connect(function(objectThatTouchesTheHitbox)
		if objectThatTouchesTheHitbox.Parent then
			if objectThatTouchesTheHitbox.Parent:FindFirstChild("Humanoid") then
				if DebounceTable[objectThatTouchesTheHitbox.Parent] == true then return end
				DebounceTable[objectThatTouchesTheHitbox.Parent] = true
				objectThatTouchesTheHitbox.Parent.Humanoid:TakeDamage(30)
				wait(2)
				DebounceTable[objectThatTouchesTheHitbox.Parent] = nil
			end
		end
	end)
end)
1 Like

just do this

local tool = --tool
local isactive = false

tool.Activated:Conenct(function()
isactive = true
wait(1)
isactive = false
end)
tool.Handle.Touched:Connect(function()
if isactive then
-- do thing
end
end)

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