Debounce Having Issues

Hey I am making a TagSystem and the debounce does not seem to work

The Issue: Whenever a player tags someone it keeps going back and forth

local debounce = false



local Character = script.parent 
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
local Player = game.Players:GetPlayerFromCharacter(Character)
print(Player.Name)


HumanoidRootPart.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") and debounce == false and Hit.Name == "HumanoidRootPart" then
		debounce = true
		local CharacterTouched = Hit.Parent
		local PlayerTouched = game.Players:GetPlayerFromCharacter(CharacterTouched)
		local RemoteEvent = game.ReplicatedStorage.Tagged
		RemoteEvent:FireServer(PlayerTouched,debounce)
		wait(1.5)
		debounce = false
	else
		if Hit.Parent:FindFirstChild("Humanoid") and debounce == true then
			wait(1.5)
			debounce = false
		end
	end
end)
1 Like

You currently have a debounce for each character. If you touch someone, your debounce becomes true but the other person’s debounce remains false, so they can instantly tag you back. I suggest you make only one debounce for everyone.

Make a new Boolean in Workspace and use it as the debounce. Use the RemoteEvent Server script to set the bool to true when it’s fired by a client.

local debounce = game.Workspace:WaitForChild("Bool")
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.