Updating text on brick with MessagingService

Currently trying to figure out how MessagingService works, and I want to change the text on the brick for every player on every existing server. However, when testing with my friend, it only updates on the server, where the brick was touched. Could anyone help me with this? Here’s what I currently have:

local messagingService = game:GetService("MessagingService")
local stringx = script.Parent.PlayerName
local pressed = script.Parent.Pressed
local text = script.Parent.SurfaceGui.TextLabel

script.Parent.Touched:Connect(function(hit)
	local character = hit.Parent
	local player = game.Players:FindFirstChild(character.Name)
	if hit.Parent:FindFirstChild("Humanoid") then
		if pressed.Value == false then
			if stringx.Value == "" then
				
				local success, errorMessage, connection = pcall(function()
					messagingService:SubscribeAsync("TestButton",function(message)
						stringx.Value = message.Data
						--print("Successfully assigned to " .. player.Name .. "!")
						text.Text = "This brick belongs to " .. player.Name .. "."
						pressed.Value = true
					end)
				end)
				
				wait(3)
				
				local success, errorMessage = pcall(function()
					messagingService:PublishAsync("TestButton", player.Name)
				end)
				
			end
		end
	end
end)

Looks like you’re only subscribing to the topic after the script.Parent.Touched event is fired.

1 Like

I want to use this for some sort of housing system, where once you claim a property, you get to keep it forever. I plan on using DataStores for it later. Should I subscribe to the topic somewhere else in the script?

1 Like

Yes, of course–Because it’s a different server that receives the message.
Also using UserId internally might be better than Name.

1 Like

Of course, however I prefer the player losing their house after, for example, changing their name on the website. It kind of matches my current view of my game that is in development, it’s subject to change though.