So this door script is supposed to let people that are on a certain team open and close it. It works absolutely fine until you die while you are on one of the buttons, and that button the person died on will not work anymore because someone died on it. And because my game is a war game, this is a problem. Output gave me nothing, and I've tried numerous other methods to fix this issue, but nothing has solved this problem. Can someone please help me? Here's the script:
debounce = false door = script.Parent.Parent.Door b1 = script.Parent b2 = script.Parent.Parent.Button2 function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") local check = game.Players:getPlayerFromCharacter(h.Parent) if (h~=nil) and debounce == false and check ~= nil then debounce = true if check.TeamColor == game.Teams:findFirstChild("North Korea").TeamColor then if door.CanCollide == false then door.CanCollide = true door.Transparency = 0.2 b1.BrickColor = BrickColor.new(28) b2.BrickColor = BrickColor.new(28) elseif door.CanCollide == true then door.CanCollide = false door.Transparency = 0.8 b1.BrickColor = BrickColor.new(21) b2.BrickColor = BrickColor.new(21) end end wait(1) debounce = false end end script.Parent.Touched:connect(onTouched)