Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why will it stay the same team if I am a Police and touch the part?? Please Help!

Asked by 4 years ago
Edited 4 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.

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)
0
Can you show us the remote events's code? jackochjulius 2 — 4y
0
A. Why are you doing Touched on the client B. Why are you attempting to change the TeamColor locally DeceptiveCaster 3761 — 4y
0
Hey jack! Sure I will do that later TgaTheGoldenArmour 15 — 4y
0
Why are you using team colour as a comparison, why not just check the player team itself. Maybe you should, in the remote event stuff, check if the player is not a police, then change it, instead of changing it back. Phyrixia 51 — 4y

Answer this question