Need help with remotes, please

So I am trying to fire a remote that switches a player’s team color. The issue is that when I do it, I always get an error, I’m doing this.

Client:

part.MouseButton1Down:Connect(function()
	clickSound:Play()
	remote:FireServer(player.Team)
	down:Play()
	unblur:Play()
end)

Server:

ServerEvents.Team.OnServerEvent:Connect(function(player, teamColor)
	player.TeamColor = BrickColor.new(teamColor)
end)

My error:

  17:55:43.361  ServerScriptService.RemoteHandler:5: invalid argument #1 to 'new' (Color3 expected, got Instance)  -  Server - RemoteHandler:5

What’s the issue and how can I fix it?

You are sending the Team Instance the Player is on, this is why you are getting this error, try sending over the TeamColor of the Player already?

I’m a bit confused, can you sum that up in lamen terms?

you are sending a “player.Team” value.

then putting that value into BrickColor.new(teamColor)
instead, try sending remote:FireServer(player.TeamColor)

part.MouseButton1Down:Connect(function()
	clickSound:Play()
	remote:FireServer(player.TeamColor)
	down:Play()
	unblur:Play()
end)

You’re using player.Team, and that’s an Instance, you must get the Team color, so would be Player.TeamColor.

This is my error when I fix the client,

  18:07:46.829  ServerScriptService.RemoteHandler:5: invalid argument #1 to 'new' (Color3 expected, got BrickColor)  -  Server - RemoteHandler:5

“(Color3 expected, got BrickColor)”, Color3.new().

Tried that, just said the opposite, BrickColor expected, got Color3.

Anyways, what’s the point of change the Player team to the current player team?

OOOOOOOOF, I meant to make it so when I click on one of the flags, it’ll change them to the flags country color. i.e, UK, USA, etc. Sorry for not explaining that.

How can I make it so when you click on one of the flags, it’ll change your team to that team on the server?

Just do player.TeamColor = teamColor

It does nothing, I’m very confused as to what to do. Should I give you some more context from the script?

Alright so, I made this script.

local flagsFolder = game.Workspace:WaitForChild("FlagsFolder")

for _, v in pairs (flagsFolder:GetChildren()) do
	v.ClickDetector.MouseClick:Connect(function(Player)
		if Player.TeamColor ~= v.BrickColor then
			if game.Teams:FindFirstChild(v.Name) then
				local selectedTeam = game.Teams:WaitForChild(v.Name)
				Player.Team = selectedTeam
			end
			
		else
			print("The player is already in the selected team.")
		end
	end)
end

https://gyazo.com/2033c5adae956a3dd4f60d578ed8ee12

The TeamColor must be the same of the Flag BrickColor!

https://gyazo.com/9d7f5b9cf6344fd2b923382e8c3925b5

Put the script in ServerScriptService.

But it’s clicking a UI, not a part.

Do the same, just with a RemoteEvent.

Oh, ok. I’ll do that. Let’s hope it works.

LocalScript:

local Frame = script.Parent

for Index, Item in pairs (Frame:GetChildren()) do
	if Item.ClassName == "TextButton" then
		Item.MouseButton1Click:Connect(function()
			if Item.Name == "USA" then
				game.ReplicatedStorage.RemoteEvent:FireServer("USA")
			elseif Item.Name == "UK" then
				game.ReplicatedStorage.RemoteEvent:FireServer("UK")
			end
		end)
	end
end

Script:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player, SelectedTeam)
	if SelectedTeam == "USA" then
		Player.TeamColor = BrickColor.new("Persimmon")
	elseif SelectedTeam == "UK" then
		Player.TeamColor = BrickColor.new("Bright blue")
	end
end)


https://gyazo.com/75a9dae2c40ced4f5459fb13717950d4

It’s sadly not working, I do believe I’ve done everything you did. I made sure it was getting the “ImageButton” not “TextButton”.

Here’s a image of my explorer and my script.

LocalScript: (ignore the ones in the buttons)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remote = ReplicatedStorage.ServerEvents.Team

for i, v in pairs(script.Parent:GetChildren()) do
	if v.ClassName == "ImageButton" then
		v.MouseButton1Click:Connect(function()
			if v.Name == "ContinentalArmy" then
				remote:FireServer("Continental Army")
			elseif v.Name == "GreatBritain" then
				remote:FireServer("Great Britain")
			end
		end)
	end
end

RemoteHandler Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerEvents = ReplicatedStorage.ServerEvents

ServerEvents.Team.OnServerEvent:Connect(function(player, selectedTeam)
	if selectedTeam == "Continental Army" then
		player.TeamColor = BrickColor.new("Bright blue")
	elseif selectedTeam == "Great Britain" then
		player.TeamColor = BrickColor.new("Bright red")
	end
end)

Picture of my explorer: