You can write your topic however you want, but you need to answer these questions:
What do you want to achieve?
I want to use change each player to a different character depending on its tea
What is the issue? Include screenshots / videos if possible!
There’s no way to (iI can find) to refer to each player
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.
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
end
if Model:FindFirstChild(PlrTeamParts) then
local Val = Instance.new("BoolValue", Model.PlrTeamParts) -- I honestly am not sure what you want to achieve...
Val.Name = v.Name
end
end
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)
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.
end
end
end
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.