I was attempting to use a script which adds specific players to a different team, which, for instance, allows them to access areas locked behind a team-only door, I do have a script which was supposed to do that, but it does not work properly.
The script which is supposed to move specific players to said team works incorrectly, the player list says that the player is in the team they were supposed to move to, but they are still in the basic team, so they cannot access team-only doors.
I have been attempting to find any help or working scripts on the Roblox Developer Forum, or scripting tutorials on YouTube, but it did not bring anything useful.
This is the code that I was using, it was supposed to be placed in StarterCharacterScripts, attempted to do so with normal scripts and local scripts.
player = game.Players.LocalPlayer
if player.Name == "Toxy4576" then -- the player name
player.Team = game.Teams.Scientists -- the team name
end
Any way I can upgrade this script to work properly, or is there any existing script which I could use? I am thankful for all help!
Why not do in ServerScriptService a PlayerAdded event and check if the UserId (since usernames can be changed) of a person is within a table of UserIds (easier use) and then change the team?
local devs = {
-- Ids here
}
game.Players.PlayerAdded:Connect(function(plr)
for _, dev in pairs(devs) do
if plr.UserId == dev then
plr.Team = game.Teams.Scientists
end
end
end)