i am having trouble on picking on which line to put the debounce for it to work
local rs = game:GetService("RunService")
local soundfolder = script.SoundFolder:GetChildren()
local debounce = true
rs.Stepped:Connect(function()
local last = nil
for i,v in pairs(game.Players:GetChildren()) do
if last == nil then
last = v
end
if debounce then
debounce = false
if last.Character and v.Character then
if last and last~= v then
local dist = (last.Character.HumanoidRootPart.Position-v.Character.HumanoidRootPart.Position).magnitude
for i,b in pairs(soundfolder) do
local randomnum = math.random(1,#soundfolder)
if i == randomnum then
local sound = b:Clone()
sound.Parent = last.Character
sound.Volume = 10
sound:Play()
if dist <= 5 then
print("The player "..v.Name.." is close to "..last.Name)
wait(5)
debounce = true
end
last = v
end
end
end
end
end
end
end)