Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i change players' team locally in a server script?

I've tried multiple ways to change the teams of players inside a table inside of a model but the only ways I've had to do that was locally which wouldn't work in a server script that I can only use. How can I make it work? Here are some of my attempts:\

for _, player in pairs(model.PlayersTouching:GetChildren()) do
    player.TeamColor = BrickColor.new("Sea green")
end

.

for i,v in pairs(model.PlayersTouching:GetChildren()) do
    v.TeamColor = BrickColor.new("Sea green")
end

.

local players = game:GetService("Players")
                for i,v in pairs(model.PlayersTouching:GetChildren()) do
                    if v.Parent:FindFirstChild("Humanoid") then
                        players:GetPlayerFromCharacter(v.Parent)
                        v.TeamColor = BrickColor.new("Sea green")
    end
end

2 comments

1

If you want to do it locally do it from a LocalScript!

0

But I don't want to do it locally

1 answer

If you want something to be done by the server but only show up locally, this is impossible. You will need to use a LocalScript to change the Player's team. You can alternatively use a RemoteEvent and :FireClient(player) to have a LocalScript change the team depending on what the Server sends the client.

For extra assistance, please contact me on Discord.

Bark#4260

This discussion is preserved as it was. New answers, comments, and votes are closed.