Debounce not functioning

hello! im making a queue system, however the debounce in the script isnt working as intended. is there anyway i could fix this

local Rep = game:GetService("ReplicatedStorage")
local StringP1 = Rep.Players.Player1.Value
local StringP2 = Rep.Players.Player2.Value
local StringP3 = Rep.Players.Player3.Value
local StringP4 = Rep.Players.Player4.Value
local QueuePad = game.Workspace:WaitForChild("QueueThing")

QueuePad.Touched:Connect(function(hit)
	local Deb = true
	local Player = hit.Parent
	local Humanoid = Player:FindFirstChildOfClass("Humanoid")
	if Deb then
		if Humanoid then
			if StringP1 == nil or game.Players:FindFirstChild(StringP1) == nil then
		StringP1 = Player.Name
		print(StringP1.. "is the first player.")
		Deb = false
		wait(2)
		Deb = true
	elseif StringP2 == nil or game.Players:FindFirstChild(StringP2) == nil then
		StringP2 = game.Players.LocalPlayer.Name
		print(StringP2.. "is the second player.")
		Deb = false
		wait(2)
		Deb = true
	elseif StringP3 == nil or game.Players:FindFirstChild(StringP3) == nil then
		StringP3 = game.Players.LocalPlayer.Name
		print(StringP3.. "is the third player.")
		Deb = false
		wait(2)
		Deb = true
	elseif StringP4 == nil or game.Players:FindFirstChild(StringP4) == nil then
		StringP4 = game.Players.LocalPlayer.Name
		print(StringP4.. "is the fourth player.")
		Deb = false
		wait(2)
		Deb = true
	else
		print("Queue is full.")
			end
		end
	end
end)

ps. sorry for the messy code

this is a local script btw, fyi

create the variable behind the function

ok, ill try that later when i have time. thanks

Try this:

local Rep = game:GetService("ReplicatedStorage")
local StringP1 = Rep.Players.Player1.Value
local StringP2 = Rep.Players.Player2.Value
local StringP3 = Rep.Players.Player3.Value
local StringP4 = Rep.Players.Player4.Value
local QueuePad = game.Workspace:WaitForChild("QueueThing")

local Deb = true
QueuePad.Touched:Connect(function(hit)
	local Player = hit.Parent
	local Humanoid = Player:FindFirstChildOfClass("Humanoid")
	if Deb then
		if Humanoid then
			if StringP1 == nil or game.Players:FindFirstChild(StringP1) == nil then
		StringP1 = Player.Name
		print(StringP1.. "is the first player.")
		Deb = false
		wait(2)
		Deb = true
	elseif StringP2 == nil or game.Players:FindFirstChild(StringP2) == nil then
		StringP2 = game.Players.LocalPlayer.Name
		print(StringP2.. "is the second player.")
		Deb = false
		wait(2)
		Deb = true
	elseif StringP3 == nil or game.Players:FindFirstChild(StringP3) == nil then
		StringP3 = game.Players.LocalPlayer.Name
		print(StringP3.. "is the third player.")
		Deb = false
		wait(2)
		Deb = true
	elseif StringP4 == nil or game.Players:FindFirstChild(StringP4) == nil then
		StringP4 = game.Players.LocalPlayer.Name
		print(StringP4.. "is the fourth player.")
		Deb = false
		wait(2)
		Deb = true
	else
		print("Queue is full.")
			end
		end
	end
end)

You just have to move the debounce variable outside of the connection.