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

Team change local script not working FE?

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

3 comments

0

use a playeradded event

0

but only server scripts can do that

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

1 answer

✓ Accepted answer

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.

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