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

Team Only Frame Color Not Working?

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

1 answer

✓ Accepted answer

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.

1 comment

0

Thanks!

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