Kick player at other servers

I creare a command kick player but it does not work if that player is on a different server. Is there any way to kick that player?

I am not a specialist in these matters but I think that only when you shotdown server player will be kicked.
:o

No there is not unless you somehow involve MessagingService to wait for you to call PublishAsync and for the script to wait for it using SubscribeAsync and verify whether a player with the specified name in the message exists in the server, and then kicking the player.

This is not too easy, is it? I don’t even know if it can be done.

Why would you need to kick the player in the other server?

It would be a lot of work as @XxELECTROFUSIONxX described (or a third-party application,) to get this to work properly. You might be better off just keeping the command available to kick from the server you are connected to.

If you feel it is necessary, then yeah. You need to be able to access all clients connected to any server which would require publishing those references to a central location in like a datastore or something (which I don’t recommend.)

Servers are independent game instances and weren’t built to communicate with each other.

Pseudo-code not to be relied totally upon, use pcalls for PublishAsync as well.

local players = game:GetService("Players")
local ms = game:GetService("MessagingService")
local remote = game.ReplicatedStorage.RemoteEvent

 ms:SubscribeAsync("Kick", function(message)
   local name = message.Data
   if pcall(function() players[name]:Kick() end) then 
      print("success")
   end
end
-- through some Gui or either something on the client,  fire an event to do this
local function kick(playerName)
    local player = players:FindFirstChild(playerName) 
    if player then player:Kick() 
 else
       ms:PublishAsync("Kick", playerName)
    end
end

remote.OnServerEvent:Connect(kick)
1 Like