I have a script here and I'm trying to change a brick's color based on the player's team color. Here is the script:

local LocalPlayer = game.Players.LocalPlayer
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local server = ChatService:AddSpeaker("Server")
server:JoinChannel("All")
server:SetExtraData("NameColor", Color3.fromRGB(255, 255, 255))
server:SetExtraData("ChatColor", Color3.fromRGB(0, 255, 255))




script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		script.Parent.Color = LocalPlayer.TeamColor.Color
		print("Brick color was changed")
		local char = hit:FindFirstAncestorOfClass("Model")
		server:SayMessage(char.Name.." has completed California in 1st place!", "All")
		print("Server said message")
		LocalPlayer.leaderstats.Stage.Value = "Utah"
		print("Stage value was changed")
	end
end)



I'm getting an error: Workspace.1stCalifornia.Script:15: attempt to index nil with 'TeamColor'

1 comment

0

Nevermind I fixed it.