Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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
1
If you want to do it locally do it from a LocalScript! User#19524 175 — 5y
0
But I don't want to do it locally Supergamerboy1995 129 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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

Ad

Answer this question