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

Why does it say I am not in the police team if I am, Help me please. Whats the problem?

Asked by
RootEntry 111
7 years ago

I tried with citizen team and that worked and then I switched to the police team but then it still says I am not a police.

Here is the localscript:

local player = game.Players.LocalPlayer
local gui = player:FindFirstChild("PlayerGui"):FindFirstChild("CarUI")
local button = gui:FindFirstChild("ButtonsFram"):FindFirstChild("CopCar")
local CivCarFrame = gui:FindFirstChild("CivCarsFrame")
local CopCarFrame = gui:FindFirstChild("CopCarsFrame")
open = true

button.MouseButton1Click:connect(function()
    if player.TeamColor == "Cyan" then
    CivCarFrame.Visible = false
    CopCarFrame.Visible = true
    else
        button.Text = "You are not police!"
        wait(2)
        button.Text = "Police Cars"
    end
end)
0
Thanks so much for your help! :D RootEntry 111 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

Your problem is on line 9. See Player API, which shows that TeamColor is BrickColor, which is never equal to a string. Instead, do player.TeamColor.Name == "Cyan" or player.Team.Name == "Police" (the second option lets you change the TeamColor and the script will still work).

0
Or compare the TeamColor to the BrickColor. Kind of hate that Roblox implemented these new properties when throughout the years, many people were fine with just BrickColors... M39a9am3R 3210 — 7y
Ad

Answer this question