Im Making a Door that only unlocks when you are on the police team but when i change team it stops working
local TweenSer = game:GetService("TweenService")
script.Parent.OpenLeftHitbox.Touched:Connect(function(hit)
if hit.Name == "HumanoidRootPart" and open == false then
open = true
local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if plr then
if plr.TeamColor == BrickColor.new("Bright blue") then
local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut,0,false,0)
local openL = TweenSer:Create(script.Parent.LeftDoor.Main, tweenInfo, {CFrame = script.Parent.LOLCFrame.CFrame})
openL:Play()
openL.Completed:Connect(function()
wait(0.3)
TweenSer:Create(script.Parent.LeftDoor.Main, tweenInfo, {CFrame = script.Parent.LeftMain.CFrame}):Play()
wait(0.8)
open = false
end)
end
end
end
end)
script.Parent.OpenRightHitbox.Touched:Connect(function(hit)
if hit.Name == "HumanoidRootPart" and open == false then
open = true
local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if plr then
if plr.TeamColor == BrickColor.new("Bright blue") then
local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut,0,false,0)
local openL = TweenSer:Create(script.Parent.LeftDoor.Main, tweenInfo, {CFrame = script.Parent.LORCFrame.CFrame})
openL:Play()
openL.Completed:Connect(function()
wait(0.3)
TweenSer:Create(script.Parent.LeftDoor.Main, tweenInfo, {CFrame = script.Parent.LeftMain.CFrame}):Play()
wait(0.8)
open = false
end)
end
end
end
end)```
Changing Team
```game.ReplicatedStorage.Events.TeamChange.OnServerEvent:Connect(function(player, TeamColor)
player.TeamColor = TeamColor
for i,v in pairs(player.Backpack:GetChildren()) do
v:Destroy()
end
end)