Is there a way to refer to all players "local player" on server

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I want to use change each player to a different character depending on its tea
  2. What is the issue? Include screenshots / videos if possible!
    There’s no way to (iI can find) to refer to each player
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I can’t seem to find anything but just using player.localplayer doesnt work because its a server script
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
--theoretical way the script would work
local allplayers = game.players.??? --some way of getting all the players?
allplayers.Character = CharacterOptions:FIndFirstChild(allplayers.Team.Name):Close()

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Just loop through all players instead of defining them all.

local AllPlayers = game:GetService("Players"):GetPlayers()  -- this gets all the players
for i, v in pairs(AllPlayers) do
	-- loop  through every individual player and do stuff to them all

how would I get the player as a variable? would i use :GetPlayers(player)) ?

What are you wanting to achieve?

well, I want to change all players’ characters by getting their team name and finding that name in a group of player models. There are probably easier ways to achieve this but this is all I can think of.

for i, v in pairs(game:GetService("Players"):GetPlayers()) do
	local PlrTeam = v.Team
	if PlrTeam == game.Teams["TEAMNAME"] then
		-- do stuff to players on this team
	elseif PlrTeam == game.Teams["TEAMNAME2"] then
		-- do stuff to players on this team
	if Model:FindFirstChild(PlrTeamParts) then
		local Val ="BoolValue", Model.PlrTeamParts) -- I honestly am not sure what you want to achieve...
		Val.Name = v.Name

I already have plans on how to change the character but the first part worked except for some weird bug where the team is incorrect (like I can be on team2 but it’ll still do the stuff for team1)

I’m almost thinking it’s a bug which sucks

The previous script provided should work and I’ve seen many similar to it be used.

Here’s a similar script example.

local Teams = game:GetService("Teams")

for _, Team in ipairs(Teams:GetTeams()) do
	for _, TeamPlayer in ipairs(Team:GetPlayers()) do
		if Team == Teams["Red"] then
			--Do stuff for players on red team.
		elseif Team == Teams["Blue"] then
			--Do stuff for players on blue team.

A bug which you created - I highly suggest studying for loops on YouTube or other Forum posts for this as using loops is often very common. Otherwise, I can write the exact code how you want if you don’t understand and as long as you give a clear explanation.

the bug doesn’t have anything to do with loops though?

What’s the bug then? What does it error? Send a screenshot of the code if possible.