Hey! I was wondering how I could make it so when a specific rank in a group (for example general manager) chats a command (like !splitteam), it changes the trainees team to randomized trainee teams.
Sorry it was sort of hard to understand.
--setting variables for services
local players = game:GetService("Players")
local teams = game:GetService("Teams")
--otherStuff
local groupId = -- put your group id here
local rank = -- put the rank thing here, eg 255
local randomTeams = {
-- put the teams here. examples below
teams.Team1
teams.Team2
}
local traineeTeam = -- trainee team
--checking for players joining
players.PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup(groupId) == rank then
plr.Chatted:Connect(function(message)
if message == "!splitteam" then
for i,v in pairs(traineeTeam:GetPlayers()) do
v.Team = randomTeams[math.Random(1,#randomTeams)]
end
end
end)
end
end)
hopefully this should work
Well for chat commands just do
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
end)
end)
Just do what he said lol
Btw I can’t do anything fancy cuz I’m on mobile lol
(S)He has a table with team instances so u don’t need to worry abt that
could you be more clear? the code i wrote basically makes it so that if a player with a certain rank in a group says !splitteam then it will make everybody in the trainee team go to a random team within the table of random teams. i dont understand what you mean
Oh, I didn’t read it carefully. Oops!
It’s ok. I didn’t read it carefully enough.
The team have to exist in order for them to be added
Edit: He forgot commas
did you set the group id and the rank before it? it could be from those not being set first
local randomTeams = {
-- put the teams here. examples below
teams.Team1,
teams.Team2,
}
as @Pure_Bacn said i forgot the commas so whoops
I did set those. I figured it out tho. Also, what does it mean by trainee teams
it’s the team you talked about in the first post. everyone in that team will get assigned to the random teams
In groups each rank have a number indicating it’s power.
So just put the power value of the rank in there.
Wait nvm I got a misread AGAIN
Do you know how to integrate that with Basic Admin Essential using their plugin thing?