Tool is dealing dmg after playing animation

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    for the script to only deal 30 dmg once

  2. What is the issue? Include screenshots / videos if possible!
    My Video 18 - YouTube

you can see that when i attack the dmg is not 30, i think thats it is becuase of the hitbox touching multiple bodyparts

as well as this now when my bat touches a dummy it also deals dmg without needing to left click

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i have tried adding a wait after the dmg script but am not able to disable it

I am extremely new to scripting as you can see and am using tutorials
the script i used is from this video
How To Make A Sword On Roblox - YouTube

please ask me anything if i didnt clarify or anything

here is the script

local DebounceTable = {}

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)

-- This is an example Lua code block

just realised i didnt put the script in the code thingy my bad

You can make a delay when player uses tool. By the way please write your code to code blocks
Here is example:

local delay = 1 -- you can change delay
local damaged = Instance.new("BoolValue")
damaged.Value = false
damaged.Changed:Connect(function()
    if damaged.Value == true then
         	damaged.Value = true
	        wait(delay)
	        damaged.Value = false
    end
end)
script.Parent:WaitForChild(“Hitbox”).Touched:Connect(function(objectThatTouchesTheHitbox)
	if damaged == false then
        damaged.Value = true
		--your code..
	end
end)

If you get an error, please let me know!

1 Like