Hello. I made this team script, and it will not work if I add debounce. I tested the script with prints and when it comes to the part where it finds the humanoid it won't work. Here is my script: I have some other locals, but that doesn't matter. The locals are assigned for teams.
local door = script.Parent
local debounce = false
door.Touched:Connect(function(hit)
if debounce == false then
debounce = true
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr.Team == Republic then
door.CanCollide = false
door.Transparency = .3
wait(1)
door.CanCollide = true
door.Transparency = .5
wait(1)
debounce = false
elseif plr.Team == RI then
door.CanCollide = false
door.Transparency = .3
wait(1)
door.CanCollide = true
door.Transparency = .5
wait(1)
debounce = false
elseif plr.Team == BlueTeam then
door.CanCollide = false
door.Transparency = .3
wait(1)
door.CanCollide = true
door.Transparency = .5
wait(1)
debounce = false
elseif plr.Team == CG then
door.CanCollide = false
door.Transparency = .3
wait(1)
door.CanCollide = true
door.Transparency = .5
wait(1)
debounce = false
elseif plr.Team == RG then
door.CanCollide = false
door.Transparency = .3
wait(1)
door.CanCollide = true
door.Transparency = .5
wait(1)
debounce = false
elseif plr.Team == RC then
door.CanCollide = false
door.Transparency = .3
wait(1)
door.CanCollide = true
door.Transparency = .5
wait(1)
debounce = false
end
end
end
end)
Hope you can help, thank you.

5 comments
The script just stops after it set debounce to true.
Use print() to print a string for each condition passed. That will help you find where the script is stopping.
I already did that. I found out the script stops after it set debounce to true.
That means it's not finding the humanoid.
How can my script find the humanoid proberly then?