alright, so it is now in my game but when a user joins and I try to promote them or someone else tries to promote them it says attempting then uh oh, we couldn’t process the promotion
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 promoteed 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)