I’m trying to send some data across all servers using MessagingService, but I cannot access it.
Basically, I want to send some data when stepped on a part:
local MessagingService = game:GetService("MessagingService")
local pickup = script.Parent
pickup.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") then
local player = game.Players:FindFirstChild(part.Parent.Name)
local data = {player.Name, pickup.Parent.Name}
messagingService:PublishAsync("Purchase", data)
end
end
end)
If I use just a print table statement:
MessagingService:SubscribeAsync("Purchase", function(data)
print(data)
end)
I get the data that I need:
But if I try to access the values (I also tried unpacking the table):
MessagingService:SubscribeAsync("Purchase", function(data)
print(data[1])
end)
The print statement is nil. How can I access the values?