Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gameKey = "" -- goes here
- local _Ranking = require(01896155381)(gameKey)
- local _Players = game:GetService("Players")
- local _Group = game:GetService("GroupService")
- local Command = "!rank" — change to whatever
- local GroupId -- set to group ID ofc
- local minRank -- set to min rank
- local function IsCommand(Message)
- local search = string.find(Message, "^" .. Command)
- return (search>-1 and true) or false
- end
- local function Parse(Message)
- local Words = {}
- for str in string.gmatch(Message, "[%w]+") do
- table.insert(Words, str)
- end
- return Words
- end
- local function GetPlayer(String)
- for i, plr in pairs(_Players:GetPlayers()) do
- if (String:lower() == plr.Name:lower():sub(1, String:len())) then
- return plr
- end
- end
- end
- local function GetRank(Role)
- local GroupInfo = _Group:GetGroupInfoAsync(GroupId)
- for i, info in pairs(GroupInfo.Roles) do
- if (info.Name:lower() == Role:lower()) then
- return info.Rank
- end
- end
- end
- local function Refresh(Player)
- if (Player.Character) then
- local Cframe = Player.Character.PrimaryPart.CFrame
- Player:LoadCharacter()
- local Char = Player.Character or Player.CharacterAdded;Wait()
- Char:SetPrimaryPartCFrame(Cframe)
- end
- end
- local function Process(Message)
- local MsgIsCmd = IsCommand(Message)
- if (MsgIsCmd) then
- local Words = Parse(Message)
- local isPlayer = GetPlayer(Words[2])
- if (isPlayer) then
- local newRank = GetRank(table.concat(Words, “ “, 3))
- if (newRank) then
- _Ranking.setRank(GroupId, isPlayer.UserId, newRank)
- wait()
- Refresh(isPlayer)
- end
- end
- end
- end
- _Players.PlayerAdded:Connect(function(Player)
- local pRank = Player:GetRankInGroup(GroupId)
- Player.Chatted:Connect(function(Message)
- if (pRank>=minRank) then
- Process(Message)
- end
- end)
- Player.CharacterAdded:Connect(function()
- pRank = Player:GetRankInGroup(GroupId)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement