Is it possible to fire a remote to the server to team the player from a string?

I have some code here, basically what this does is fire a remote to the server to change the player to a certain team used with strings (“”).

This all seems to work well, printing, etc but the teaming part of this does not seem to be working.
This made me discombobulated, due to the fact I’m firing the teams name with a string to the server, then finding the first child with the contents of that team. Dejectedly, I’m unsure if this is possible or not, but if it is please don’t hesitate to enunciate!

Server:
local Services = require(game:GetService(“ReplicatedStorage”).Modules.ScriptModules.Services)

Services.ReplicatedStorage.Remotes.Events.MenuEvent.OnServerEvent:Connect(function(Player, Type, …)
if Type == “ChangeTeam” then
local Team = …
print(“team”)
Player.Team = Services.Teams:FindFirstChild(Team)
end
end)

Client Script:
local CurrentTeam = “Test Subject”
local MenuEvent = game.ReplicatedStorage.Remotes.Events.MenuEvent

MenuEvent:FireServer(“ChangeTeam”, CurrentTeam)

Yes, this is definitely possible. Also, please use the styling thing for code so it looks neat. My question is what is this module and why are you using it?

The services module is what I use for storing game services, like run service, etc instead of putting it in multiple variables inside the code.

Just to keep in mind it’s almost 2 AM where I live so I am depressingly tired and I forgot where the thing is where it makes your text go into code-like.

To me, that causes more problem than actually making it easier for yourself. Just use game:GetService without the modules. Is there any error with your code?

I do not think so, everything seems to work fine except teaming the player.

I can provide gifs if essential.

OK, also what is the triple dots, can you change that to something else, like a word? This is a three-dot operator, I’m pretty sure it’s not meant to be used in this situation.

Ah, I’ll see.
Btw gif.
https://gyazo.com/ee23ed7f68a42cd4dbb9fd1f7f6a849a

I have changed the … argument to a word, and it still does not function (I removed the variable for it as well.)

I suggest you rewriting your code to something simpler, like remove the Services module thing first and when it’s fixed, you can add it back.

Alright. I’ll see how I go. 30 characters.

Rewritten.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Teams = game:GetService("Teams")

ReplicatedStorage.Remotes.Events.MenuEvent.OnServerEvent:Connect(function(Player, Type, Team)
	if Type == "ChangeTeam" then
		print("team")
		Player.Team = Teams:FindFirstChild(Team)
	end
end)

Everything works fine except the Player.Team bit, so it’s definitely that.

Alright, just let me check.

This script works for me:


--// LOCAL
wait(4)
local CurrentTeam = "Test Subject"
local MenuEvent = game.ReplicatedStorage.RemoteEvent
MenuEvent:FireServer("ChangeTeam", CurrentTeam)

--// SERVER
local RS = game:GetService("ReplicatedStorage")

RS.RemoteEvent.OnServerEvent:Connect(function(Player, Type, TeamName)
if Type == "ChangeTeam" then
local Team = TeamName
Player.Team = game.Teams:FindFirstChild(Team)
print(TeamName)
end
end)

Okay so, what I did wrong was with the client script when the player clicks play, I printed the “Team” variable and it’s a capital version of the team, should I do :lower() or is that not the solution.

Because in this bit of team selection, it makes it capitalised.

ClickSound:Play()
CurrentTeam = i:upper()
GUI.Selected.Text = "SELECTED TEAM: " .. CurrentTeam

Hold on, let me ask again. You want to change the Player’s team to something new, right? If so, why are you passing the currentTeam value?

I have a table of teams which involves their names and required group ids and ranks.
With the table I can handle team changing, so then I can capitalize the current team variable to change the text to that (as my menu is capitalized).

This is nothing about capitalization, you’re simply not changing the team if you look at your code again. Your script is pretty much like this:

local currentTeam = player.Team

--SETTING THE NEW TEAM
player.Team = currentTeam

That’s basically your script if you look at it again, hence why it won’t change anything.