Virvek
(Virvek)
March 28, 2020, 10:19pm
#1
Every time I try to send the second message in the parameter, it comes out nil on the receiving end:
Sending the message:
MessageService:PublishAsync("BattleServer", "Test", "TestTwo")
Receiving the message:
MessageService:SubscribeAsync("BattleServer",function(MessageOne, MessageTwo)
print(MessageOne.Data) -- Prints "Test"
print(MessageTwo.Data) -- Prints "Nill"
end)
Virvek
(Virvek)
March 28, 2020, 10:28pm
#2
Would it be better to combine the two messages as one string, and then once we receive the message, split it with a specific character inside the string?
("Test,TestTwo")
-- Then Split the string when finding ","
("Test".."TestTwo")
It’s the only other workaround I can find…
You can try sending it in a table, like this:
MessageService:PublishAsync("BattleServer", {"Test", "TestTwo"})
MessageService:SubscribeAsync("BattleServer",function(Messages)
Messages = Messages.Data
print(Messages[1])
print(Messages[2])
end)
13 Likes
Virvek
(Virvek)
March 28, 2020, 10:33pm
#4
It worked, thank you very much!
3 Likes