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

[SOLVED BY ME]Script is not damaging the second humanoid?

The script I'm using could be incorrect or wrongly timed. I have no clue, so could anyone help? Here's the script.

local weapon = script.Parent.Parent.Handle.HitPart
local dmg = script.Parent.Parent.Interval.Value * 50 -- Damage

weapon.Touched:Connect(function(part)
	if part.Parent:FindFirstChild("Humanoid") then
		local humanoid = part.Parent:FindFirstChild("Humanoid")
		humanoid:TakeDamage(dmg)
		script:Destroy()
		if dmg then
			dmg:Destroy()
		end
	end
end)

I hope this gets answered. Also, can anyone also tell me what debounce is? Because this script is a free model, but I want to learn about it. Thanks.

Edit: Okay, I fixed it. Feel free to make any suggestions or possibly, tell me what in the world a debounce is.

1 answer

Hey, no answer on your script but answer on your question on debounce! Debounce is something we use to make a cooldown. Here's an example!

debounce = true

if debounce == true then
	debounce == false
	wait(1)
	debounce = true
end

If it's still not clear, here's another example!

block = script.Parent
debounce = true				 --Debounce can be called anything!

block.Touched:connect(function(hit)
	if debounce == true then		--This checks if the cooldown is ready
		debounce = false		--This starts the cooldown
		block.BrickColor = BrickColor.Random()
		print(hit)
		wait(2) 				--This is how long the cooldown lasts
		debounce = true		--This ends the cooldown
	end
end)

1 comment

0

Thank you! Now I understand!

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