Need help with rank system. (ref,Kick)

Hello.
I have promote demote commands. Need when ranker promote user, ref and kick player. When: “!promote user”, player ref and kicked. Please help

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, "Promote Info","User be promoted!")
						game.Players.PlayerAdded:connect(function(p)
							end)
					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)


Can you put it in proper tags please?

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, "Promote Info","User be promoted!")
						game.Players.PlayerAdded:connect(function(p)
							end)
					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)





Okay, you can add the kick feature by using the kick function:

player:kick("Kick text here")

Ok, that for spef player?

Working. But ranker kicked when user promoted. Need player who been promoted by ranker been kicked

Can you make command for the promoted player? Not for ranker

It’s because you’re passing the wrong player object to kick. It’s not efficient to make a spare command for the ranker.

Can you show me the script that you had working, in code tags?

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