Using messaging service

I know how to publish and get message using messaging service.

Publishing data:

pcall(function()
    game:GetService("MessagingService"):PublishAsync("JAdminKickBannedPlayer")
end)

Getting data:

game:GetService("MessagingService"):SubscribeAsync("JAdminKickBannedPlayer", function()
	-- Some code.
end)

But I want to ask: how to publish and get player’s to kick name?

Please answer with code and what are you doing there (optionally, I will understand but some people may not).

1 Like

Forgive me if I misunderstood, but it sounds like you want to kick a player from another server?

Well, you’d probably send the player’s UserId via messaging service and have every receiving end check if they have that player in their server. If they do find that player, then kick them. I don’t think it’s that complicated, so I’m sure you can figure it out for yourself :slightly_smiling_face:

Yes, but I want to know how to send player’s name and get the data using messaging service.

1 Like

Here is the documentation of Messaging Service. I’m sure you can find everything you need there!

Edit: A more useful documentation, sorry I linked the wrong one.

1 Like

to get the message inside the function the first argument is the message. The message is a table and to get the data you need to use message.Data . An example

game:GetService("MessagingService"):SubscribeAsync("JAdminKickBannedPlayer", function(message)
print(message.Data) -- Players name or whatever you are sending and receiving

end)

Hope this helps

2 Likes

To publish the message do this

pcall(function()
    local message = player.Name -- As an example
    game:GetService("MessagingService"):PublishAsync("JAdminKickBannedPlayer",message)
end)
2 Likes