Promote and demote bug - Other users can use the command

hey! promote and demote work for others that arent supposed to use it
min rank is 255 (should only be for me accessed)

Hello and welcome to the forums!

Can we the script your using? Make sure to remove any credentials!

local HttpService = game:GetService(“HttpService”)
local ReplicatedStorage = game.ReplicatedStorage
local AppUrl = script.AppUrl.Value
local ApiKey = script.ApiKey.Value
local Groupid = script.GroupId.Value
local MinRank = script.MinRank.Value
local prefix = “!”

local function FindPlr(plr)
local foundPlr = nil
local plrs = game.Players:GetPlayers()
for i = 1, #plrs do
local current = plrs[i]
if string.lower(current.Name):sub(1, #plr) == string.lower(plr) then
foundPlr = current.Name
break
end
end
return foundPlr
end

game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if player:GetRankInGroup(Groupid) >= 2 then
local LowerCaseMessage = string.lower(msg)
if string.find(LowerCaseMessage, prefix… “promote”) then
local SplitMessage = string.split(msg, " “)
local full_player = FindPlr(SplitMessage[2])
if full_player == nil then
local playerInstance = game.Players:FindFirstChild(player.Name)
game.ReplicatedStorage.Notify:FireClient(playerInstance, “Uh-Oh.”,“We couldn’t find the player you wanted to promote!”)
else
local playerInstance = game.Players:FindFirstChild(player.Name)
game.ReplicatedStorage.Notify:FireClient(playerInstance, “Attempting.”,“Attempting to promote user…”)
local Url = script.AppUrl.Value…“group/promote?user_name=”…full_player…”&key=" …script.ApiKey.Value…“&groupid=”…script.GroupId.Value
local success, response = pcall(function()
local response = HttpService:GetAsync(Url)
local data = HttpService:JSONDecode(response)
end)
if success then
game.ReplicatedStorage.Notify:FireClient(playerInstance, “Horrah!”,“We promoted the user!”)
else
game.ReplicatedStorage.Notify:FireClient(playerInstance, “Uh-Oh.”,“We had problems promoting the user.”)
end
end
else if string.find(LowerCaseMessage, prefix… “demote”) then
local SplitMessage = string.split(msg, " ")
local full_player = FindPlr(SplitMessage[2])
if full_player == nil then
local playerInstance = game.Players:FindFirstChild(player.Name)
game.ReplicatedStorage.Notify:FireClient(playerInstance, “Uh-Oh.”,“We couldn’t find the player you wanted to demote!”)
else
local playerInstance = game.Players:FindFirstChild(player.Name)
game.ReplicatedStorage.Notify:FireClient(playerInstance, “Attempting.”,“Attempting to demote user…”)
local Url = script.AppUrl.Value…“group/demote?user_name=”…full_player… “&key=” …script.ApiKey.Value… “&groupid=” …script.GroupId.Value
local success, response = pcall(function()
local response = HttpService:GetAsync(Url)
local data = HttpService:JSONDecode(response)
end)
if success then
game.ReplicatedStorage.Notify:FireClient(playerInstance, “Horrah!”,“We demoted the user!”)
else
game.ReplicatedStorage.Notify:FireClient(playerInstance, “Uh-Oh.”,“We had problems demoting the user.”)
end
end
end
end
end
end)
end)

Thanks, can you put that in code tags though?

not sure how to put it in code tags

We reccommend to search before asking!

I found this with a quick search.

im confused on what you mean

Take a look at the following post that I linked!

it has ends in the script i sent above…

local HttpService = game:GetService("HttpService")

local ReplicatedStorage = game.ReplicatedStorage

local AppUrl = script.AppUrl.Value

local ApiKey = script.ApiKey.Value

local Groupid = script.GroupId.Value

local MinRank = script.MinRank.Value

local prefix = "!"

local function FindPlr(plr)

local foundPlr = nil

local plrs = game.Players:GetPlayers()

for i = 1, #plrs do

local current = plrs[i]

if string.lower(current.Name):sub(1, #plr) == string.lower(plr) then

foundPlr = current.Name

break

end

end

return foundPlr

end

game.Players.PlayerAdded:Connect(function(player)

player.Chatted:Connect(function(msg)

if player:GetRankInGroup(Groupid) >= 2 then

local LowerCaseMessage = string.lower(msg)

if string.find(LowerCaseMessage, prefix.. "promote") then

local SplitMessage = string.split(msg, " ")

local full_player = FindPlr(SplitMessage[2])

if full_player == nil then

local playerInstance = game.Players:FindFirstChild(player.Name)

game.ReplicatedStorage.Notify:FireClient(playerInstance, "Uh-Oh.","We couldn't find the player you wanted to promote!")

else

local playerInstance = game.Players:FindFirstChild(player.Name)

game.ReplicatedStorage.Notify:FireClient(playerInstance, "Attempting.","Attempting to promote user...")

local Url = script.AppUrl.Value.."group/promote?user_name="..full_player.."&key=" ..script.ApiKey.Value.."&groupid="..script.GroupId.Value

local success, response = pcall(function()

local response = HttpService:GetAsync(Url)

local data = HttpService:JSONDecode(response)

end)

if success then

game.ReplicatedStorage.Notify:FireClient(playerInstance, "Horrah!","We promoted the user!")

else

game.ReplicatedStorage.Notify:FireClient(playerInstance, "Uh-Oh.","We had problems promoting the user.")

end

end

else if string.find(LowerCaseMessage, prefix.. "demote") then

local SplitMessage = string.split(msg, " ")

local full_player = FindPlr(SplitMessage[2])

if full_player == nil then

local playerInstance = game.Players:FindFirstChild(player.Name)

game.ReplicatedStorage.Notify:FireClient(playerInstance, "Uh-Oh.","We couldn't find the player you wanted to demote!")

else

local playerInstance = game.Players:FindFirstChild(player.Name)

game.ReplicatedStorage.Notify:FireClient(playerInstance, "Attempting.","Attempting to demote user...")

local Url = script.AppUrl.Value.."group/demote?user_name="..full_player.. "&key=" ..script.ApiKey.Value.. "&groupid=" ..script.GroupId.Value

local success, response = pcall(function()

local response = HttpService:GetAsync(Url)

local data = HttpService:JSONDecode(response)

end)

if success then

game.ReplicatedStorage.Notify:FireClient(playerInstance, "Horrah!","We demoted the user!")

else

game.ReplicatedStorage.Notify:FireClient(playerInstance, "Uh-Oh.","We had problems demoting the user.")

end

end

end

end

end

end)

end)
1 Like

It looks as if it’s hardcoded, try setting the number 2 to be MinRank


If this works for you mark it as soloution!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.