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

Team change local script not working FE?

Asked by 5 years ago

I want all the devs to be on the devs team and the players on the players team but it doesn't seem to be working.

plr = game.Players.LocalPlayer

repeat wait()until game.Players.LocalPlayer.ChildAdded

if plr.Name == "Gamerasassin514" or plr.Name == "DailyMadlymarthan" or plr.Name ==      "UwaisPlayz" then
    plr.Team = game.Teams.Devs
    plr.TeamColor = BrickColor.new("Royal purple") 
end

if plr.Name ~= "Gamerasassin514" or plr.Name ~= "DailyMadlymarthan" or plr.Name ~=  "UwaisPlayz" then
    plr.Team = game.Teams.Players
    plr.TeamColor = BrickColor.new("Bright red")
end
0
use a playeradded event User#23365 30 — 5y
0
but only server scripts can do that User#23365 30 — 5y
0
if it is on a local script make a remote event that fires so a regular script will handle it or if it is already a script try using game:GetService("Teams") make sure the game items actually exist before attempting to find an item within the game stinkyest11 78 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

FE prevents changes made by code in LocalScripts from replicating to the server automatically (with exceptions).

--Put this in a normal Script under ServerScriptService or Workspace.


PlayerService = game:GetService('Players')
CurrentPlayers = PlayerService:GetPlayers()

TeamService = game:GetService('Teams')
DevTeam = TeamService:WaitForChild('Devs')
PlayerTeam = TeamService:WaitForChild('Players')


----------------------------

--Names of the Players you want on the Devs team go inside this table

DevNames = {
    'Gamerasassin514',
    'DailyMadlymarthan',
    'UwaisPlayz'
}

----------------------------


function NameCheck(Player)

    local Name = Player.Name

    for i = 1, #DevNames do
        if DevNames[i] == Name then
            Player.Team = DevTeam
            break
        else
            Player.Team = PlayerTeam
        end
    end

end


PlayerService.PlayerAdded:Connect(NameCheck)


for i = 1,#CurrentPlayers do
    NameCheck(CurrentPlayers[i])
end

Make sure the teams "Devs" and "Players" have already been created, and their AutoAssignable property is disabled.

If there's anything you don't understand, ask, and I'll do my best to answer.

Ad

Answer this question