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

What is the deal with my debounce not doing it's job?

I made a damage script, that damages a player 20 + some other numbers. Then the game makes a gui that floats over the player that was hit. But for some reason, the debounce does not work properly and i hit more than 2-3 times instead of only once.

Strong.Touched:connect(function(hit)
if not debounce then return end
debounce = false
local opponent = hit.Parent:findFirstChild("Humanoid") or hit.Parent.Parent:findFirstChild("Humanoid")
		if opponent and opponent ~= player.Character.Humanoid then
		if opponent.Parent:findFirstChild("RicoStacks") then
opponent.Parent:findFirstChild("RicoStacks").Value = opponent.Parent:findFirstChild("RicoStacks").Value + 1
local dmg = math.floor(script.Parent:FindFirstChild("Charging").Value / 1.55 + baseAtk + 1 + opponent.Parent:findFirstChild("RicoStacks").Value/2)
		   opponent:TakeDamage(dmg)
------------------------------------------------------
-----------------[Text/Gui and debounce]---------------------------
local effect = Instance.new("BillboardGui", opponent.Parent.Head)
effect.Size = UDim2.new(1,0,1,0)
wait()
	local text = Instance.new("TextBox")
	text.Parent = effect
	text.TextSize = 60
	text.TextColor3 = Color3.new(255,0,0)
	text.TextStrokeColor3 = Color3.new(170,0,0)
	text.Font = "Cartoon"
	text.BackgroundTransparency = 1
	text.Size = UDim2.new(1,0,1,0)



text.Text = dmg
for i = 0,5 do
	wait(0.04)
	effect.StudsOffset = Vector3.new(0,i,0)
end
wait(0.2)
effect:destroy()		
end		
end
wait(0.4)
debounce = true	
end)

1 answer

I believe you forgot to put "local debounce = true" on line #1.

1 comment

0

local doesn't matter

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