How would I kick non-admins from a team if they try to switch to that team?
admin where? in a group? you can use player:getrankingroup(group id)
and check if they got the rank
like a list of players that are allowed to be in a certain team, but if other players try to join that team, they get kicked
you can constantly check the team for the players in it with a loop, and check if their user id (or name) is part of the list
or even better, when adding the player to the group, check if their name or user id, is part of the list, if not dont add them to the team
Where is the list? You need to specify, is it an array? You can check when a user joins the team to check if they are in that array, I can give you an example if you can provide the “list”
https://developer.roblox.com/en-us/api-reference/event/Team/PlayerAdded
This is the event that fires when a user is added to a team.
KonoKore and ximeremix are the 2 main admins
<Team>.PlayerAdded:Connect(function(player)
if not player.Name == "KonoKore" or not player.Name == "ximeremix" then
-- do whatever you want if the person is not an admin
end
end)
HORRIBLE solution.
Not only will this break if the user changes their username, but ximeremix will always be kicked off the team because you forgot to add not to the second condition.
The code below should work:
local admins = {1074726208, 155025104} -- admin user ids here, add as many as youd like
<Team>.PlayerAdded:Connect(function(player)
if not table.find(admins, player.UserId) then
-- do what youd like with non admins who have joined the team
end
end)
I couldn’t be bothered to go get their id, I am sure they are smart enough to figure that out them selves
Are u sure? I’ve seen a lot of this Damn world and uh, Everybody seems to be Dumb
Where should i specifically put this script at, and what kind?
You can put it in a script inside ServerScriptStorage
You should actually put it in serverscriptservice, no such thing as serverscriptstorage im pretty sure
You used their username + no table, you cant assume everyone knows this stuff