Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

0

Thanks so much for your help! :D

1 answer

✓ Accepted answer

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).

1 comment

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...

This discussion is preserved as it was. New answers, comments, and votes are closed.