Hello, I have made this code where when a prisoner or citizen hits a part they change to crims. It succefully worked. I wanted it so if a police toches the part it will stay the same team but it did not work. Please have a look at my code and see if you can help me fix it. The main code needing to be fixed is at the very bottom.
The main code is at the bottom.
local RemoteEvent = game.ReplicatedStorage.ChangeTeam local CriminalEvent = game.ReplicatedStorage.Criminals -- variables local PoliceEvent = game.ReplicatedStorage.Police local CrimFrame = game.StarterGui.ScreenGui.CrimsTeam -- ignore this and go to bottom local PoliceDevice = game.Teams local PoliceTeamTest = game.Teams.Police local player = game.Players.LocalPlayer local frame = script.Parent:WaitForChild("Frame") local player = game.Players.LocalPlayer local red = game.Workspace.Parts.RedBrick local CitizensColor = "Lime green" local PoliceColor = "Cyan" local PrisonersColor = "Bright orange" local CriminalsColor = "Crimson" frame.Prisoners.MouseButton1Click:Connect(function() RemoteEvent:FireServer(BrickColor.new(PrisonersColor)) end) frame.Police.MouseButton1Click:Connect(function() RemoteEvent:FireServer(BrickColor.new(PoliceColor)) end) frame.Citizens.MouseButton1Click:Connect(function() RemoteEvent:FireServer(BrickColor.new(CitizensColor)) end) -- THE CODE IS BELOW! red.Touched:Connect(function() CriminalEvent:FireServer(BrickColor.new(CriminalsColor)) local PoliceTestRun = 100 if player.TeamColor == PoliceColor and PoliceTestRun == 100 then player.TeamColor = PoliceColor -- not keeping the police the same team code end end)