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)