Purpose: to make a script that will read a players team color, and then if there color is red or blue it will choose what color to make the scripts frame background color. Unfortunately my attempt failed. If you could help me out that would be awesome and thanks for reading! Code:
if workspace.Gamestart == true then local plrs = game:GetService("Players") AllPlayers = {plrs} BlueTeam = AllPlayers.Team("Bright blue team") RedTeam = AllPlayers.Team("Bright red team") if AllPlayers.LocalPlayer == RedTeam then local BackGround = script.Parent.BackgroundColor3 BackGround = script.Parent.BackgroundColor3.new(202, 1, 1) if AllPlayers.LocalPlayer == BlueTeam then local BackGround = script.Parent.BackgroundColor3 BackGround = script.Parent.BackgroundColor3.new(30, 53, 202) end end end end
It can be done very simply like so (in a LocalScript in either StarterPlayer.StarterPlayerScripts or StarterGui):
local player = game.Players.LocalPlayer -- Why it needs to be a LocalScript. This can't be done by the server. game.Workspace.Gamestart.Changed:connect(function() -- When the value of workspace.Gamestart changes, it updates it's color. if game.Workspace.Gamestart.Value == true then script.Parent.BackgroundColor = player.TeamColor -- If you do "BackgroundColor" instead, it requires a BrickColor rather than a Color3. else -- If it's value is false. script.Parent.BackgroundColor = BrickColor.White() -- I assume that you want a default color when the game is not running. end end)
If you have any questions, feel free to message me or reply to this answer.