In Roblox Studio, I decided to create a Global Message system that allows specific players to submit a message using a custom command, /announce! Eventually, once making the code while following the tutorial, everything seemed normal… Until a message on the Output tab appeared stating the argument is got something else that should not be expected
local MessageService = game:GetService("MessagingService")
local ReplictedStore = game:GetService("ReplicatedStorage")
local Players = game.Players
local Notification = ReplictedStore.GlobalAnnouncementSystem:WaitForChild("Notify")
local Command = "/announce"
Players.PlayerAdded:Connect(function(player)
if (player).Name == "JuanGamerPlayz_RBLX" and "Viewported" then
player.Chatted:Connect(function(message)
local SplitMessage = message:split(" ")
if (SplitMessage)[1] == Command then
MessageService:PublishAsync("Global Announcement", message:sub(tostring(SplitMessage[1]), " "))
Notification:FireAllClients(player, "Success", "Your Message has been fully sent.")
end
end)
end
end)
MessageService:SubscribeAsync("Global Announcement", function(Message)
Notification:FireAllClients("Global Announcement", Message["Data"])
end)
Can someone help me out with this? I appreciate the support!
Now it is giving a warning line in the Notification:FireAllClients(player, "Success", "Your Message has been fully sent.")… Not sure why the script is not working as expected from this tutorial:
local MessageService = game:GetService("MessagingService")
local ReplictedStore = game:GetService("ReplicatedStorage")
local Players = game.Players
local Notification = ReplictedStore.GlobalAnnouncementSystem:WaitForChild("Notify")
local Command = "/announce"
Players.PlayerAdded:Connect(function(player)
if (player).Name == "JuanGamerPlayz_RBLX" and "Viewported" then
player.Chatted:Connect(function(message)
local SplitMessage = message:split(" ")
if (SplitMessage)[1] == Command then
MessageService:PublishAsync("Global Announcement", message:gsub(tostring(SplitMessage[1]), " "))
Notification:FireAllClients(player, "Success", "Your Message has been fully sent.")
end
end)
end
end)
MessageService:SubscribeAsync("Global Announcement", function(Message)
Notification:FireAllClients("Global Announcement", Message["Data"])
end)
Basically, if I create a variable called Juan and View where it waits for us to join the game, it can be possible to put the variables in the if statement and continue further with the progress! (Actually, while messaging you, I just thought straight ahead that it would be better if get the names through a table/by UserId, but uncertain how it could be structured afterwards in the code lines.)
Okay, so I have returned to the script replacing the event with FireClient and once testing the command such as saying “/announce Hi”, it seems that in the Output, it prints an error stating that FireClient is not a valid member somehow