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

How to make a Certain rank be on a Certain Team?

Okay, so I've been working on a Restaurant and need help making a certain rank go on a certain team. I've tried looking at yt videos but most of them don't work, and a lot don't have the script in the des. Also a lot of them have blurry screens and I cannot see! .Please help, I really want to have a successful game for once!

1 answer

✓ Accepted answer

Hey there,

In order to do what you are trying to do, you might want to have a look into teams and GetRankInGroup(), as this will give you a better understanding on the code below.

If you want to have multiple teams for multiple ranks, you can just add more if statements.

local team = game:GetService("Teams") -- the team service

local groupId = 1 -- The group which you are trying to get the rank from

local rank = player:GetRankInGroup(groupId) -- returns a number between 0 and 255

if(rank == 255) then -- owner rank
	player.Team = teams["Owner"] -- Owner is the team's name
end

-- If you want to team anyone above a certain rank, you can use >=

If you have any further questions, feel free to ask them, I'm happy to help!

[EDIT]

Since that you seem to be having some struggles with using this, I'll be providing additional help.

You will want to run this code when a player joins, so that they are placed in the right team once they join. We do so, by connecting to the PlayerAdded event.

-- Script
-- To be placed in the ServerScriptService

local players = game:GetService("Players") -- The player service
local team = game:GetService("Teams") -- the team service

local groupId = 1 -- The group which you are trying to get the rank from

players.PlayerAdded:Connect(function(player)  -- player is the player that joined the game
	local rank = player:GetRankInGroup(groupId) -- returns a number between 0 and 255

	if(rank == 255) then -- owner rank
		player.Team = teams["Owner"] -- Owner is the team's name
	end
end)

6 comments

1

Thanks!

1

Omg! TYSM! I will certainly give credits. This helped me so much!

0

You don't know how happy I am to know that I helped! :) Good luck with your restaurant! <3

0

Just to be sure where do we put the script? In teams?

0

I'm assuming that you have some scripting knowledge, but in case you don't, let me edit my answer

0

There we go, hope that this helps you!

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