Im making a kind of debounce thing to my code so it doesnt run twice when its not supposed to. I use the debounce like
local db = false
while true and db == false do
task.wait(1)
(code)
db = true
end
Im using a while true do loop for doing alot of if statements every second until the debounce is true. I can see that the debounce is equal to true but it still runs. Ive searched for quite a while but no result. Thanks.
I tried this but, no effect. Heres the part of the code if you need it.
local db = false
repeat task.wait(2)
if game.Workspace:FindFirstChild("clone") then
local distance = game.Players.LocalPlayer:DistanceFromCharacter(game.Workspace:WaitForChild("clone").Position)
if distance <= 50 then
local db = true
print(db)
local playerpos = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
game.Workspace.deathbox:FireServer(playerpos)
end
end
until db
local player = game.Players.LocalPlayer
local db = false
repeat task.wait(2)
if not workspace:FindFirstChild("clone") then
continue
end
if player:DistanceFromCharacter(workspace.Clone.Position) <= 50 then
db = true
workspace.deathbox:FireServer(player.Character.HumanoidRootPart.Position)
end
until db
on the side note:
do not put remote events under workspace (its unorganized) rather, make a folder under replicated storage
using a remote event for this leaves a vulnerability where an exploiter could fire that remote abunch of times