Group Management

Group Management Script for Roblox

Easily manage your group’s members with our versatile script!

:rocket: Model: Group Manager Model

Instructions:

  1. Add the model to ServerScriptService.
  2. Edit the GroupConfig within the Group module.
  3. Update the ID to match your group.
  4. Update the Name to match your group.
  5. Insert the following code into your script:

local group = require(game.ReplicatedStorage.GroupManager)

Available Functions:

  • GetNewRoleInGroup(player)
  • GetNewRoleIDInGroup(player)
  • GetRoleIDInGroup(player)
  • GetRankInGroup(player)
  • GetGroupOwnerID(player)
  • GetGroupOwnerName(player)
  • GetGroupName()
  • GetGroupDescription()
  • GetGroupImage()
  • GetGroupID()

Example Usage:

local group = require(game.ReplicatedStorage.Group)

game.Players.PlayerAdded:Connect(function(plr)
    print(group.GetRoleInGroup(plr)) -- Prints the player's current rank name
    wait(5) -- Waits 5 seconds before ranking the player to a specific rank
    print(group.GetNewRoleInGroup(plr)) -- Prints the player's new rank name
end)

print(group.Description()) -- Prints the group description```

Here’s some issues I noticed within the module.

Issue 1

Your codebase utilizes no types; so I’m assuming your trying to use the Player Class not a string?

function group:GetRoleFromPlayer(player)
		if game.Players:FindFirstChild(player) then
			if GroupInfo.Print == true then
				print(GroupInfo["Success Title"].." We have successfully executed GetRoleFromPlayer function.")
			end
			return game.Players[player]:GetRoleInGroup(group:GroupId())
		else
			error(GroupInfo["Error Title"].." There was a error while executing GetRoleFromPlayer function, please contact RobloxCooler aka The owner.")
			return
		end
	end

Issue 2

Instead of an if statement I would recommend using assert() instead.

Example;

function group:GetRoleFromPlayer(Player: Player)
assert(Player ~= nil and typeof(Player) == "Instance" and Player:IsA("Player"))
end

This validates it’s a Player and not nil. Optionally you can also add a custom error message to it.

Issue 3

Your codebase does not contain any sort of pcalls for any errors that could occur from GetRoleInGroup failing.

Example;

local success: boolean, err: string? = pcall(function()
error("This will fail!")
end)

if not success then
warn(err)
-- Your custom error handling logic...
end

Issue 4

I recommend utilizing Metatables to support multiple groups.

Example;
Sorry for no indents, writing code on the forum sucks.

local GroupService = game:GetService("GroupService")

local GroupAPIWrapper = {}
GroupAPIWrapper .__index = GroupAPIWrapper;

function GroupAPIWrapper.new(GroupId: number)
local self = setmeatable({}, GroupAPIWrapper)
self.GroupId = GroupId;
return self;
end

function GroupAPIWrapper:GetRoleInGroup(Player: Player)
...
end

return GroupAPIWrapper;

Issue 5

What’s the point of GetRoleFromPlayer and UpdatedRank? They both call the same function, To my knowledge Roblox caches your Group roles calling it again does not refresh it for a while?*

Issue 6

Your script checks if the ModuleScript is a descendant of ServerScriptService and named Group, but in your example of this post you have it located in ReplicatedStorage named GroupManager?

Hope this info helps you out.

Kind Regards,
vq9o.

1 Like

Ah, posted the wrong asset ID. updating my post rn.

1 Like

Anyone needs help? Contact me via DMs

Did you like ignore @vq9o 's feedback or something?

No no no, I forgot to input the new asset ID, that’s all, the new module does a check.