Remote event fires once, then stops working

Hi! I have a tool script and when you activate the tool, it runs 3 remote events. But one of the remote events fire once normally, and then you use the tool again (after the cooldown) it doesn’t fire or the server doesnt put up the remote event. here is the code below:

--this is a local script
local blackholeclone = game.ReplicatedStorage.Remotes.CloneBlackhole
local checkbh = game.ReplicatedStorage.Remotes.CheckBlackhole
local check2bh = game.ReplicatedStorage.Remotes.CheckBlackhole2
local twentyseccd = game.ReplicatedStorage.Remotes["20SecCD"]
local getplayerbh = game.ReplicatedStorage.Remotes.Getplayeybh
local debounce = false
local ifblackhole = true
local checkifrotating = tool.Parent:FindFirstChild("BlackHoleRotate")
tool.Activated:Connect(function()
	if debounce == false  then
		debounce = true
		print("Activated")
		checkbh:FireServer()
		local anim = script.Parent.JumpAnim
		local humanoid = player.Character.Humanoid
		local animtrack = humanoid:LoadAnimation(anim)
			ifblackhole = false
			print("set bh to false")
			if debounce == true and ifblackhole == false then
				animtrack:Play()
				task.wait(0.8)
				getplayerbh:FireServer(player)
				blackholeclone:FireServer(player)
				twentyseccd:FireServer()
				task.wait(20)
				
				debounce = false
			end

		
	end

end)

below is the code for the server side of the remote event, “getplayerbh” or “Getplayeybh”

--this is a server script
local hitbox = script.Parent
local players = game:GetService("Players")
local callrotate = game.ReplicatedStorage.Remotes.CallRotate
local lbremote = game.ReplicatedStorage.Remotes.Lightsaber
local getplayerbh = game.ReplicatedStorage.Remotes.Getplayeybh
local debounce = false
local whosimmune = script.Parent.Parent.Immune
local DAMAGE = 2
local INTERVAL = 1

local touchingHumanoids = {}

script.Parent.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid then
		touchingHumanoids[humanoid] = true
		getplayerbh.OnServerEvent:Connect(function(player)
			print("doing blackhole code")
			lbremote:FireClient(player)
			whosimmune.Name = player.Name
			
			if hit.Parent:FindFirstChild("Humanoid") ~= nil and not hit.Parent:FindFirstChild("BlackHoleRotate") and hit.Parent.Name ~= whosimmune.Name then
				print("is touching")
				local blackholescript = game.ReplicatedStorage.Scripts.BlackHoleRotate:Clone()
				blackholescript.Parent = hit.Parent
				callrotate:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
				print("done")
			end

			local clonekillscript = game.ServerStorage.DebuffScripts.KillLB:Clone()

			if hit.Parent:FindFirstChild("KillLB") == nil then
				if humanoid.Health > 0 and hit.Parent.Name ~= whosimmune.Name then
					clonekillscript.Parent = humanoid.Parent
				end


			else
				if humanoid.Health > 0 and hit.Parent.Name ~= whosimmune.Name then
					hit.Parent.KillLB:Destroy()
					clonekillscript.Parent = humanoid.Parent
				end


			end
			
		end)
	end
end)

script.Parent.TouchEnded:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid and hit.Parent.Name ~= whosimmune.Name then
		touchingHumanoids[humanoid] = nil
	end
end)

while true do
	for humanoid in pairs(touchingHumanoids) do
		humanoid:TakeDamage(DAMAGE)
	end
	task.wait(INTERVAL)
end

The debounce makes this unreachable after using it once. Also when the ifblackhole is true, the debounce locks the tool entirely down and you can’t use it again. The fix narrows down to this:

tool.Activated:Connect(function()
	if debounce == true then
		return
	end
	print("Activated")

	debounce = true
	checkbh:FireServer()
	local anim = script.Parent.JumpAnim
	local humanoid = player.Character.Humanoid
	local animtrack = humanoid:LoadAnimation(anim)

	animtrack:Play()
	task.wait(0.8)

	getplayerbh:FireServer(player)
	blackholeclone:FireServer(player)
	twentyseccd:FireServer()

	task.wait(20)
	debounce = false
end)
1 Like

i put in your new code for the tool, and it does the exact same thing. perhaps it could be something with the server?

The client code would not change much apart from fixing that one bug of stopping to work.

tool.Activated:Connect(function()
	if not debounce then
		debounce = true
		checkbh:FireServer()
		local anim = script.Parent.JumpAnim
		local humanoid = player.Character.Humanoid
		local animtrack = humanoid:LoadAnimation(anim)
		animtrack:Play()
		task.wait(0.8)
		getplayerbh:FireServer(player)
		blackholeclone:FireServer(player)
		twentyseccd:FireServer()
		task.wait(20)
		debounce = false
	end
end)

that doesnt work either, i think it might be the server code that i put above