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

Debounce not working. Kills player instead of damage. How do i fix it?

I made an ability that creates a beam and damages the player but instead of 35 dmg it kills them.

Here is the Code:

local remote = game.ReplicatedStorage.BarrierBeam

remote.OnServerEvent:Connect(function(plr,mouseaim)
	local parts = game.ServerStorage.Classes.BarrierMaster
	local BeamLoc = parts.BarrierBeam
	local Beam = BeamLoc:Clone()
	Beam.Parent = workspace
	Beam.CFrame = CFrame.new(mouseaim)
	local dmg = game.Workspace.BarrierBeam.Damagepart
	game.Debris:AddItem(Beam, 1.7)
	wait(1.5)
	dmg.Transparency = 0.6
	dmg.Touched:Connect(function(hit)
		for i,v in pairs(workspace:GetChildren()) do
			local Debounce = false
			if hit.Parent:FindFirstChild("Humanoid")and Debounce == false and hit.Parent.Name ~= plr.Name then
				Debounce = true
				hit.Parent.Humanoid:TakeDamage(35)
				wait(2)
				Debounce = false											
						end
		end
		end)
end)

2 answers

✓ Accepted answer
    dmg.Touched:Connect(function(hit)
        for i,v in pairs(workspace:GetChildren()) do
            local Debounce = false -- you are setting the debounce every time it touches something. This line should be next to "local remote" on line 2 above the whole function. Then you can remove this line here
            if hit.Parent:FindFirstChild("Humanoid")and Debounce == false and hit.Parent.Name ~= plr.Name then
                Debounce = true
                hit.Parent.Humanoid:TakeDamage(35)
                wait(2)
                Debounce = false                                            
                        end
        end
        end)
end)

1 comment

0

ty

Maybe At line 18 put hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 35

1 comment

0

It still kills them

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