Why Isn't Debounce Working On 5+ Speed

local deb = false
local PunchBack = game.Workspace:FindFirstChild(“PunchBag”)
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
PunchBack.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
player.leaderstats.Speed.Value = player.leaderstats.Speed.Value + 5
print(player.Name…“Touched!”)

		if not deb then
			
			deb = true
			
			print("Button was touched!")
			
			wait(3)
			
			deb = false
		end

	end

end)

end)

It should be a script, not a localscript.
The script that you should use:

local deb = false
script.Parent.MouseButton1Click:Connect(function()
PunchBack.Touched:Connect(function(hit)
if not deb then

if hit.Parent:FindFirstChild(“Humanoid”) then
local player = game.Players[hit.Parent.Name]
player.leaderstats.Speed.Value += 5
print(player.Name..“ Touched!”)
deb = true
wait(3)
deb = false
end
		end
end)
end)

The’s, Should be a local script!

local deb = false
local PunchBack = game.Workspace:FindFirstChild("PunchBag")
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	if not deb then
		task.wait(0.5)
		deb = false
	end
	PunchBack.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			wait(0.6)
			deb = true
			player.leaderstats.Speed.Value = player.leaderstats.Speed.Value + 5
				print(player.Name.."Touched!")	
	
          end
		
	end)
end)

it only does debounce when the button is first clicked

it doesnt work its still giving speed way to fast

it doesnt work its stll giving speed too fast

ok so your problem:
first) you’re adding to a leaderstats value thru a localscript
solution) fire a remote event to the server and add it there
second) you used PunchBag.Touched and put it in the mousebutton1click event
solution) you can check if mouse.Target == PunchBag and if it is then fire the remote event and turn on debounce make sure the remoteevent is in the debouce if statement

-- Localscript prefereablly in startergui
local deb = false
local PunchBag= game.Workspace:FindFirstChild(“PunchBag”)
local player = game.Players.LocalPlayer

local mouse = player:GetMouse()

mouse.Button1Click:Connect(function()
       if deb then return end -- if debounce == true then do not run anymore
       if mouse.Target ~= PunchBag then return end -- if mouse.target is not the punchbag then do not run anymore
       deb = true
       
       remoteeventname:FireServer(5) -- 5 is the amount you wanna give

       task.wait(5) -- delay
       deb = false
end)

-- Server script definitly in ServerScriptService

remoteeventname.OnServerEvent:Connect(function(player, amount)
      player.leaderstats.Speed.Value += amount -- add the amount to the speed value
end)

make a remote event in replicated storage name it what ever you want and change remoteeventname to the remote events path

for ex:
game.ReplicatedStorage.AddSpeed
also: there are ofc other better ways but this is just my way

you can also check how far the player is from the punchbag if you want me to add that please inform me