Hello! I just got into the BETA program and trying out the MessagingService.
After some time learning about it, I tried to make a simple thing i thought
I made so when I say “/officialshow NOTE_HERE” it publishes data to all of the servers so they can join my current server.
PublishAsync
if string.sub(msg, 1, 14) == "/officialshow " then
MessagingService:PublishAsync("OfficialShow", string.sub(source, 15), player.Name, player.UserId, game.JobId)
end
After that I made a function that handles all of the GUI’s in the other servers when it Subscribes.
You don’t have to unpack anything. The arguments are passed as a vararg, so you just need to change your OfficialShow function declaration to take a vararg, and then use it.
local function OfficialShow(...)
local text, presenter, num, instanceId = ...
--rest of the code
end
local function OfficialShow(data)
local text, presenter, num, instanceId = unpack(data)
local Gui = game.ReplicatedStorage:WaitForChild("OfficialShowGui"):WaitForChild("MainFrame")
--Gui.ProfilePicBackground.ProfilePic.Image = "https://www.roblox.com/headshot-thumbnail/image?userId=" .. tonumber(num) .. "&width=420&height=420&format=png"
Gui.PresenterName.Text = tostring(presenter)
Gui.PresenterText.Text = tostring(text)
game.ReplicatedStorage:WaitForChild("OfficialShowGui").id.Value = instanceId
game.ReplicatedStorage:WaitForChild("Functions"):WaitForChild("MessagingService"):FireAllClients("OfficialShow")
print("Official Show Gui Fired!")
end
Player Chatted Publish
game.Players.PlayerAdded:connect(function(player)
if player.Name == "Danii_ox" then
player.Chatted:connect(function(msg)
local source = msg
msg = string.lower(msg)
if string.sub(msg, 1, 14) == "/officialshow " then
MessagingService:PublishAsync("OfficialShow", string.sub(source, 15), player.Name, player.UserId, game.JobId)
print("Official Show Message Detected!")
end
end)
end