I am making this thing where it takes the scoreboard in place A, and sends the info the place B, the menu. I am wondering why it isn’t working.
Place A - Publishers
local MessagingService = game:GetService("MessagingService")
local Players = game:GetService("Players")
local deb = false
local val = workspace.ScoreboardValues
for i,v in pairs(workspace.ScoreboardValues:GetChildren()) do
if v.Name == "StringPeriod" or v.Name == "HomeScore" or v.Name == "GuestScore" or v.Name == "HomeAbv" or
v.Name == "HomeColor" or v.Name == "GuestColor" or v.Name == "Time" then
v.Changed:Connect(function()
-- Publish to topic
if deb == false then
deb = true
local publishSuccess, publishResult = pcall(function()
local message = val.StringPeriod.Value .. " - " .. val.Time.Value
MessagingService:PublishAsync("GS1Neutral", message)
end)
local publishSuccess, publishResult = pcall(function()
local message = val.HomeAbv.Value .. " " .. val.HomeScore.Value
MessagingService:PublishAsync("GS1Home", message)
end)
local publishSuccess, publishResult = pcall(function()
local message = val.GuestScore.Value .. " " .. val.HomeAbv.Value
MessagingService:PublishAsync("GS1Guest", message)
end)
local publishSuccess, publishResult = pcall(function()
local message = val.HomeColor.Value.R*255 .. "," .. val.HomeColor.Value.G*255 .. "," .. val.HomeColor.Value.B*255
MessagingService:PublishAsync("GS1HomeColor", message)
end)
local publishSuccess, publishResult = pcall(function()
local message = val.GuestColor.Value.R*255 .. "," .. val.GuestColor.Value.G*255 .. "," .. val.GuestColor.Value.B*255
MessagingService:PublishAsync("GS1GuestColor", message)
end)
if not publishSuccess then
end
wait(7.5)
deb = false
end
end)
end
end
function new()
local publishSuccess, publishResult = pcall(function()
local message = #game.Players:GetChildren()
MessagingService:PublishAsync("GS1Count", message)
end)
if not publishSuccess then
print(publishResult)
end
end
game.Players.PlayerAdded:Connect(new)
game.Players.PlayerRemoving:Connect(new)
Place B - Receiver
local MessagingService = game:GetService("MessagingService")
local Players = game:GetService("Players")
local s1 = script.Parent.buttons.PlayFrame.Arenas.Score1
repeat wait() until game.Players.LocalPlayer
while wait() do
-- Subscribe to the topic
local subscribeSuccess, subscribeConnection = pcall(function()
return MessagingService:SubscribeAsync("GS1Neutral", function(message)
local da = message.Data
s1.N.Text = da
end)
end)
local subscribeSuccess, subscribeConnection = pcall(function()
return MessagingService:SubscribeAsync("GS1Home", function(message)
local da = message.Data
s1.HS.Text = da
end)
end)
local subscribeSuccess, subscribeConnection = pcall(function()
return MessagingService:SubscribeAsync("GS1Guest", function(message)
local da = message.Data
s1.AS.Text = da
end)
end)
local subscribeSuccess, subscribeConnection = pcall(function()
return MessagingService:SubscribeAsync("GS1HomeColor", function(message)
local da = message.Data
s1.HS.BackgroundColor3 = Color3.fromRGB(da)
end)
end)
local subscribeSuccess, subscribeConnection = pcall(function()
return MessagingService:SubscribeAsync("GS1GuestColor", function(message)
local da = message.Data
s1.AS.BackgroundColor3 = Color3.fromRGB(da)
end)
end)
local subscribeSuccess, subscribeConnection = pcall(function()
return MessagingService:SubscribeAsync("GS1Count", function(message)
local da = message.Data
s1.Parent.Count1.Count.Text = da .. "PLAYERS"
end)
end)
if subscribeSuccess then
-- Unsubscribe from topic upon player ancestry change
end
end