MessagingService:PublishAsync(): Cannot publish Instance, can only accept valid UTF-8 characters

local messagingService = game:GetService("MessagingService")

local success, errorMessage, connection = pcall(function()
	messagingService:SubscribeAsync("PlayerInQueue",function(Queue)
		print(Queue.Data)
	end)
end)

game.ReplicatedStorage.JoinedQueue.OnServerEvent:Connect(function(LocalPlayer)
	messagingService:PublishAsync("PlayerInQueue",LocalPlayer)
end)

When the JoinedQueue event is received it gives this error:
“MessagingService:PublishAsync(): Cannot publish Instance, can only accept valid UTF-8 characters.”
(The script isn’t finished yet, I just want to know how to fix this issue.)

1 Like

I’m pretty sure that means it can only accept text and not instances.
Instead, you could use LocalPlayer.Name as a fix.

2 Likes

That fixed it, but then how would it be able to receive the player and not just their Name?

Actually, you can use LocalPlayer.UserId, and then get the player by user id using game.Players:GetPlayerByUserId().

1 Like