I have a quick question about how Message Service works…
The parameter of PublishAsync, message
which is a Variant
.
Does this mean I can only pass a string? Or does passing the Values Table I made work completely fine?
local MessagingService = game:GetService("MessagingService")
local Values = {
Num = 5,
String = "Boom",
Bool = true
}
local PublishSuccess, PublishResult = pcall(function()
MessagingService:PublishAsync("Topic", Values)
end)
game.Players.PlayerAdded:Connect(function(Player)
local Connection = MessagingService:SubscribeAsync("Topic", function(Value)
print(Value.Num, Value.String, Value.Boom)
end)
Player.AncestryChanged:connect(function()
-- Unsub from topic.
Connection:Disconnect()
end)
end)