why will it stay the same team if I am a Police and touch the part?? Please Help!
Asked by
5 years ago Edited 5 years ago
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.
01 | local RemoteEvent = game.ReplicatedStorage.ChangeTeam |
02 | local CriminalEvent = game.ReplicatedStorage.Criminals |
03 | local PoliceEvent = game.ReplicatedStorage.Police |
05 | local CrimFrame = game.StarterGui.ScreenGui.CrimsTeam |
07 | local PoliceDevice = game.Teams |
09 | local PoliceTeamTest = game.Teams.Police |
11 | local player = game.Players.LocalPlayer |
13 | local frame = script.Parent:WaitForChild( "Frame" ) |
15 | local player = game.Players.LocalPlayer |
17 | local red = game.Workspace.Parts.RedBrick |
19 | local CitizensColor = "Lime green" |
20 | local PoliceColor = "Cyan" |
21 | local PrisonersColor = "Bright orange" |
22 | local CriminalsColor = "Crimson" |
24 | frame.Prisoners.MouseButton 1 Click:Connect( function () |
25 | RemoteEvent:FireServer(BrickColor.new(PrisonersColor)) |
29 | frame.Police.MouseButton 1 Click:Connect( function () |
30 | RemoteEvent:FireServer(BrickColor.new(PoliceColor)) |
35 | frame.Citizens.MouseButton 1 Click:Connect( function () |
36 | RemoteEvent:FireServer(BrickColor.new(CitizensColor)) |
42 | red.Touched:Connect( function () |
43 | CriminalEvent:FireServer(BrickColor.new(CriminalsColor)) |
44 | local PoliceTestRun = 100 |
45 | if player.TeamColor = = PoliceColor and PoliceTestRun = = 100 then |
46 | player.TeamColor = PoliceColor |