Weird Tool Glitch

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!
    I’m making a fanmade forsaken character, and they have a pitchfork as their sword.

  2. What is the issue? Include screenshots / videos if possible!
    For some reason, my script to damage people when they’re hit by the pitchfork completely kills them instead of taking away 10 health.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried different ways of taking away health
    I tried different ways of checking if its a player model

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

My script:

local debounce = false

script.Parent.Handle.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and not debounce then
		debounce = true
		local humanoid = hit.Parent.Humanoid

		-- Reduce health by 10, but ensure it doesn't go below 0
		humanoid:TakeDamage(10)

		-- Reset debounce after a short delay
		wait(1)  -- Adjust the time (in seconds) as needed
		debounce = false
	end
end)

I would appreciate any help :slight_smile:

1 Like

Try putting a print statement to see how much health the humanoid has before and after you deal damage. Maybe the debounce isn’t working properly and it’s firing too many times

There’s so many easy ways to do this lol but i’ll just give you one of the trillion ways to fix ur script

script.Parent.Handle.Touched:Connect(function(hit)

local humanoid = hit.Parent:FindFirstChild('Humanoid')

local debounce = hit.Parent:FindFirstChild('1')

if humanoid and not debounce then

local one = Instance.new('Folder')

one.Parent = hit.Parent

one.Name = '1'

humanoid:TakeDamage(10)

task.wait(1)

debounce:Destroy()

end

end)

Enjoy :slight_smile:

1 Like

thats basically the same as OP’s code but u create a folder for debounce instead of just using a bool variable

is the handle/pitchfork just a single mesh part, or is the pitchfork made up of multiple parts that are grouped together?

or perhaps, is the kill script also applied to the entire npc?

1 Like

i just used my avatar as a testing rig, it has no scripts in it. The handle of my tool is a part with a mesh in it.

this one still didn’t work… it works exactly the same, completely killing them.

I just found my issue! I have a failsafe tool in replicated storage, incase the players normal one doesn’t load. The issue was simply just i forgot to change the script in that one.