I have tried many things, yet this debounce still isn't working out for me. The script keeps on printing multiple of "rilgundam has the Red Flag!" Please help me if you can.
local hasFlag = false
local Thing = true
local DeBounce = false
function accessBackpack(hit)
if hit and hit.Parent then
local chara = hit.Parent
local player = game.Players:GetPlayerFromCharacter(chara)
local backpack = player:FindFirstChild("Backpack")
local flag = backpack:FindFirstChild("RedFlag")
if flag and flag.Parent == backpack and hasFlag == true then
return "RedFlag"
else
return print("No flag")
end
end
end
script.Parent.RedFlag.Handle.Touched:Connect(function(char)
if DeBounce == false then
DeBounce = true
hasFlag = true
if char and char.Parent then
local player = game.Players:GetPlayerFromCharacter(char.Parent)
if player then--check if they are a player
if char.Parent:FindFirstChild("Humanoid") then
if char.Parent.Humanoid.Health > 0 then--if they are still alive
print(player.Name .. " has the Red Flag!")
char.Parent:FindFirstChild("Humanoid").Died:Connect(function()
print("Person who has flag died!")
if char.Parent:FindFirstChild("RedFlag") or accessBackpack(char) and hasFlag == true then --if they die and they have the flag in their hand or backpack
hasFlag = false
local FlagClone = game:GetService("ServerStorage"):WaitForChild("RedFlag"):Clone()--the flag gets cloned and put into workspace
FlagClone.Parent = game.Workspace
FlagClone.Handle.CFrame = CFrame.new(char.Parent.Head.Position)
FlagClone:WaitForChild("Handle").Anchored = true
Thing = false
wait(3)
Thing = true
FlagClone.Handle.Touched:Connect(function()
wait(Thing)
if FlagClone.Parent.Parent == game.Workspace then
FlagClone.Handle.Anchored = false
end
end)
end
end)
end
end
end
end
DeBounce = false
end
end)

22 comments
I did that and it still doesn't work
on line 51, the end of the first end statement
Please help me
I'd like you to edit your question's code, so I can see your edits.
Ok
Read my edit.
Lol ok
K I edited it. Is it ok now?
Much better. Just DAMN INDENT PROPERLY OK??????????????????
Ok
I used the indent script and this is what it came out with. Btw, the debounce still isn't working it still says: "rilgundam has the Red Flag!"x3
Thats strange. Did you stand on it for 6 seconds?
No
I walked across it and it said what I told u
Strange. Try printing the value of debounce in the touched event before the if statement.
Ok
But shouldn't it be false because that's what the variable is
I want to see the value when the player touches it to see what problem it is, if it is the check, the debounce, etc.
So what should I do?
You can reread my comments, you know...
It said that debounce is false
Only once or multiple times???