VIP Server Kick Button

So, I am trying to add a button to my game that only VIP server owners can use. For example, if you own a VIP server on Jailbreak, you can click a button to kick any player in the server. I was wondering how I can put a similar feature in my game? It can also be something similar to the kick function in Fishing Simulator where you type in the chat to kick someone. :kick PlayerName

1 Like

Hello, you can use PrivateServerOwnerID, which gives the UserId of the VIP Server owner!

You can connect a MouseButton1Click event to the button that kicks the player in a textlabel for example.

4 Likes

you can do that by doing this in a server script:

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(chat)
		if plr.UserId == game.PrivateServerOwnerId then
			if string.find(chat, "!kick") then
			local plr = string.gsub(chat, "!kick ", "")
				if game.Players:FindFirstChild(plr) ~= nil then
				game.Players:FindFirstChild(plr):Kick("The Private Server Owner Has Kicked You!")
				end
			end
		end
	end)
end)
3 Likes
--// Local script (put in a button of course)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild(name of remote)
-- Create a remote event in replicated storage
-- Create a button for each player in the server
-- This script goes in one of those buttons
-- (Although it's probably better to use one script that controls all the buttons)
-- Make sure there's an object value inside of the button that has the value of the player it's assigned to

local button = script.Parent
local assignedPlayer = button:WaitForChild(name of object value)

button.MouseButton1Down:Connect(function()
	-- function is called when the button is right clicked
	Remote:FireServer(assignedPlayer.Value) -- tell server to kick the player
end)

--// Server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild(remote name)

Remote.OnServerEvent:Connect(function(player1, player2)
	-- player1 is the player being kicked
	-- player2 is the person kicking the player
	if player2.UserId == game.PrivateServerOwnerId and player1 ~= nil then
		-- Make sure player2 is the owner of the private server and make sure player2 is trying to kick an existing player
		player2:Kick("The private server owner kicked you from the game")
	end
end)
3 Likes