How to send data to a certain player across servers

hello.

I want to know what i should use to be able to send data to a player across another server
what do i mean?

well,

i want one player to be able to, lets say. Click a button, that then would fire a remote event in the certain players game, by using there userID

any where i can start on this?

2 Likes

Use messaging service on the server side

I know about messaging service, but is there an actual way to fire a remote event using messaging service?

Heres a quick example, but aside from this kind of approach, no

local Ms = game:GetService("MessagingService")
local Remote:RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("MyRemoteEvent")
local Players = game:GetService("Players")

Ms:SubscribeAsync("TopicExample",function(message)
	--[[
		message = {
			data <string>,
			toPlayer <userId>,
		}	
	]]
	local player = Players:GetPlayerByUserId(message.toPlayer)
	
	if player then
		Remote:FireClient(player,message.data)
	end
	
end)
1 Like

So would the target player get the remove event received?

yes, just make sure you have their userId

1 Like

the code just stops at

> Ms:SubscribeAsync("TopicExample",function(message)

any reason why?

You need to PostAsync first, subscribe async doesn’t start a topic, it listens for one. So make sure to publish async when a player presses the button

local button = script.Parent
local postevent = game.ReplicatedStorage.PostEvent
button.Activated:Connect(function()
   postevent:FireServer()
end)
—[[Server]]—
postevent.OnServerEvent:Connect(function(plr)
   local sendtoplr = — smth here
   Ms:PublishAsync(“TopicExample”, sendtoplr)
end)

It doesnt do anything on its own its listening for a PublishAsync

i just ended up finding a new resource after a few hours, thanks for trying to help tho!

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