You can write your topic however you want, but you need to answer these questions:
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.
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.
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)
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)
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.