Can you show us what data looks like/give us some info on what it contains?
To me it looks like you’re trying to send a player by your SubscribeAsync call. You can’t send an instance, you can only send strings, booleans, numbers, or tables that contain those.
On a sidenote data contains a table which contains two more fields, Data and Sent (or TimeSent, can’t remember the specific field name). So instead of indexing data itself, you’d index data.Data
Is player a player instance? If that’s the case, you’d have to manually write in the player’s user ID and name in your PublishAsync call.
For filtering text, I’d suggest doing that before the PublishAsync call as well
So for example:
function field:Subscribe()
MessagingService:SubscribeAsync(topic,function(data)
local template = script.Template:Clone()
template.ImageLabel.Image = players:GetUserThumbnailAsync(data.Data.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420)
template.Title = data.Data.Message -- on a sidenote I think this may need to be template.Title.Text
template.Name = data.Data.Name
template.Parent = script
return template
end)
end
---------
FunctionStorage.PublishMessage.OnServerInvoke = function(player,data)
warn(data)
MessagingService:PublishAsync(topic, {
Message = Chat:FilterStringForBroadcast(data.Message, player);
UserId = player.UserId;
Name = player.Name
})
end