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)
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)