Problem with debounce

local teleporter = script.Parent.Parent.Teleport
local GameS = game.ReplicatedStorage:FindFirstChild("Remotes").Game    
local db = true
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and GameS.Value == true and db == true then
        db = false
        hit.Parent:MoveTo(teleporter.Position)
		local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		local deaths = player:FindFirstChild("stats"):FindFirstChild("Deaths")
        if deaths then
            deaths.Value += 1
        end
        db = true
    end
end)
1 Like

Your debounce is immediately being set to true, there’s no wait inbetween. Try this

local teleporter = script.Parent.Parent.Teleport
local GameS = game.ReplicatedStorage:FindFirstChild("Remotes").Game    
local db = true
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and GameS.Value == true and db == true then
        db = false
        hit.Parent:MoveTo(teleporter.Position)
		local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		local deaths = player:FindFirstChild("stats"):FindFirstChild("Deaths")
        if deaths then
            deaths.Value += 1
        end
		wait(5)
        db = true
    end
end)

Waits 5 seconds before debounce is true

1 Like

This then?

local teleporter = script.Parent.Parent.Teleport
local GameS = game.ReplicatedStorage:FindFirstChild("Remotes").Game    
local playerDebs = {}

script.Parent.Touched:Connect(function(hit)
	local char = hit.Parent
    if char:FindFirstChild("Humanoid") and GameS.Value == true and not playerDebs[char.Name] then
		playerDebs[char.Name] = true
        char:MoveTo(teleporter.Position)
        if game:GetService("Players"):GetPlayerFromCharacter(hit.Parent):FindFirstChild("stats"):FindFirstChild("Deaths") then
            game:GetService("Players"):GetPlayerFromCharacter(hit.Parent):FindFirstChild("stats"):FindFirstChild("Deaths").Value += 1
        end
		wait(5)
        playerDebs[char.Name] = false
    end
end)

Put each debounce for each player in a table, sorry, I didn’t read the last bit correctly

1 Like