So I made a team only door, and I want the 'Building Station [2]' team to be able to go through, and my other team 'Citizens' to not be able to go through, and every time I go through immediately after touching the part to be put on the 'Building Station [2]' team, it lets me go through, but when I touch the door while being a citizen, then become a 'Building Station [2]' member, then touch the door it does not work. Anybody know how to fix this? Thanks.
wait()
local team = game:GetService("Teams")["Drilling Station [2]"].TeamColor
local db = false
function onTouch(hit)
if db == false then
db = true
if game.Players:GetPlayerFromCharacter(hit.Parent) ~= nil then
if game.Players:GetPlayerFromCharacter(hit.Parent).TeamColor == team then print(hit.Parent.Name.. "is a allowed inside the factory because he is in the " .. game.Players:GetPlayerFromCharacter(hit.Parent).Team.Name.. " Team.")
workspace.RedBit.BrickColor = BrickColor.new(177, 229, 166)
script.Parent.Transparency = 0.5
script.Parent.CanCollide = false
workspace.press:Play()
wait(2)
script.Parent.Transparency = 0.2
script.Parent.CanCollide = true
workspace.RedBit.BrickColor = BrickColor.new(255, 89, 89)
wait(1)
db = false
return
end
end
end
end
script.Parent.Touched:Connect(onTouch)

2 comments
Next time instead of writing in title "When I do This" explain your problem pls
there wasnt enough room :/