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

Why can't I change the team color of all players on an event?

The issue seems to be near .TeamColor = "Lavender"
If you see anything else wrong tell me.

local Goal = script.Parent
local debounce = false
local GoalVal = script.Parent.Goals

function onTouch(part)
	local Ball = part.Parent:findFirstChild("ScoreBall")
	if Ball ~= nil and debounce == false then
		local Mes = Instance.new("Message")
		Mes.Text = "Blue Team Scored!"
		Mes.Parent = game.Workspace
		GoalVal.Value = GoalVal.Value + 1
		debounce = true
		wait(5)
		local pl = game.Players:GetChildren()
		for i=1,#pl do
		pl[i].Character.Humanoid.Health = 0
		Mes:Remove()
		debounce = false
		end
	end
	end

Goal.Touched:connect(onTouch)

function Endgame()
	wait(4.9)
	local Mesa = Instance.new("Message")
	Mesa.Text = "Blue Team Has Won"
	local pla = game.Players:GetChildren()
		for i=1,#pla do
		pla[i].TeamColor = "Lavender" -- HERE
		GoalVal.Value = 0
		game.Workspace.Field.RGoalTrigger.Goals.Value = 0
		wait(10)
		Mesa.Text = "Teams And Scores Reset."
		wait(3)
		Mesa:Remove()
	end
end

while true do
	wait(.0001)
if GoalVal.Value == 2 then
	Endgame()
end
end

1 answer

✓ Accepted answer
.TeamColor = BrickColor.new("Lavender")

Try that! Should work Brickcolor returns a value known as brickcolor and a string is not a brickcolor so you got to convert it :D

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