Hello! So I am working on a promotion, demotion, fire and blacklist command for someone but have came to an issue with the commands in which it will try to rank the user twice when you run it once. I am not sure on why it is having this issue as I have used the same ranking JS in my own projects before so I don’t think it is that problem.
Script:
local GlitchURL = “Not here for security reasons!”
local DataStoreService = game:GetService(“DataStoreService”)
local webMain = “Not here for security reasons!”
local webBlackList = “Not here for security reasons!”
local http = game:GetService(“HttpService”)
local BlackList = DataStoreService:GetDataStore(“BlackList”)
local function DiscordSend(PlayerWhoBlack, PlrBlacklisted, TypeSend)
if TypeSend == "Blacklist" then
local data = {
['embeds'] = {{
['title'] = "**Player "..TypeSend.."!**",
['description'] = PlayerWhoBlack.." has blacklisted "..PlrBlacklisted,
['color'] = 837366,
}}}
local final = http:JSONEncode(data)
http:PostAsync(webBlackList, final)
end
end
game.Players.PlayerAdded:Connect(function(plr)
local success, currentExperience = pcall(function()
local UserDataBlacklst = BlackList:GetAsync(plr.UserId)
if UserDataBlacklst == true then
plr:Kick("Sorry you have been blacklisted from Mokató!")
end
end)
end)
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local LowerMessage = string.lower(msg)
if string.find(LowerMessage, "!promote") then
if plr:GetRankInGroup(8371309) >= 14 then
local Split = string.split(msg, " ")
if Split[2] then
local RealPlayer = game.Players:FindFirstChild(Split[2])
if RealPlayer then
if RealPlayer:GetRankInGroup(8371309)<= 3 then
game.ReplicatedStorage.MokatoSystem.ToLowRank:FireClient(plr)
else
if RealPlayer:GetRankInGroup(8371309) >= 8 then
game.ReplicatedStorage.MokatoSystem.CannotRank:FireClient(plr)
else
local PlayerToRankID = RealPlayer.UserId
local RoleAlready = RealPlayer:GetRankInGroup(8371309)
local RoleToRankTo = RoleAlready + 1
game:GetService("HttpService"):GetAsync(GlitchURL .. "ranker?userid=" .. PlayerToRankID .. "&rank=" .. RoleToRankTo)
DiscordSend(plr.Name, RealPlayer.Name, "Promoted")
end
end
end
end
end
else if string.find(LowerMessage, "!demote") then
if plr:GetRankInGroup(8371309) >= 14 then
local Split = string.split(msg, " ")
if Split[2] then
local RealPlayer = game.Players:FindFirstChild(Split[2])
if RealPlayer then
if RealPlayer:GetRankInGroup(8371309)<= 3 then
game.ReplicatedStorage.MokatoSystem.ToLowDemote:FireClient(plr)
else
if RealPlayer:GetRankInGroup(8371309) >= 9 then
game.ReplicatedStorage.MokatoSystem.CannotDemote:FireClient(plr)
else
local PlayerToRankID = RealPlayer.UserId
local RoleAlready = RealPlayer:GetRankInGroup(8371309)
local RoleToRankFrom = RoleAlready - 1
game:GetService("HttpService"):GetAsync(GlitchURL .. "ranker?userid=" .. PlayerToRankID .. "&rank=" .. RoleToRankFrom)
DiscordSend(plr.Name, RealPlayer.Name, "Demoted")
end
end
end
end
end
else if string.find(LowerMessage, "!blacklist") then
if plr:GetRankInGroup(8371309) >= 14 then
local Split = string.split(msg, " ")
if Split[2] then
local RealPlayer = game.Players:FindFirstChild(Split[2])
if RealPlayer then
if RealPlayer:GetRankInGroup(8371309)>= 17 then
game.ReplicatedStorage.MokatoSystem.RankHigherBot:FireClient(plr)
else
local PlayerToRankID = RealPlayer.UserId
local RankTo = 1
game:GetService("HttpService"):GetAsync(GlitchURL .. "ranker?userid=" .. PlayerToRankID .. "&rank=" .. RankTo)
local success, err = pcall(function()
BlackList:SetAsync(PlayerToRankID, true)
end)
if success then
RealPlayer:Kick("You have been blacklisted!")
DiscordSend(plr.Name, RealPlayer.Name, "Blacklist")
end
if err then
game.ReplicatedStorage.MokatoSystem.ErrorBlackList:FireClient(plr)
end
end
end
end
end
else if string.find(LowerMessage, "!fire") then
if plr:GetRankInGroup(8371309) >= 14 then
local Split = string.split(msg, " ")
if Split[2] then
local RealPlayer = game.Players:FindFirstChild(Split[2])
if RealPlayer then
if RealPlayer:GetRankInGroup(8371309)<= 3 then
game.ReplicatedStorage.MokatoSystem.ToLowFire:FireClient(plr)
else
if RealPlayer:GetRankInGroup(8371309) >= 9 then
game.ReplicatedStorage.MokatoSystem.CannotFire:FireClient(plr)
else
local PlayerToRankID = RealPlayer.UserId
local Firerank = 1
game:GetService("HttpService"):GetAsync(GlitchURL .. "ranker?userid=" .. PlayerToRankID .. "&rank=" .. Firerank)
DiscordSend(plr.Name, RealPlayer.Name, "Fired")
end
end
end
end
end
end
end
end
end
end)
end)