I am trying to get the server to send a message to the chat that someone has unboxed something.
But… come to find out it only sends a message for the player.
-- Server script:
Remotes.ShowChatItemUnboxed:FireAllClients({
Text = "[Server]: "..Player.Name.." has unboxed ["..ItemModule.GetRarity(ChosenItem).."] ".. ItemModule.GetInfo(ChosenItem).."!";
Color = ItemModule.GetRarityColor(ChosenItem);
Font = Enum.Font.SourceSansBold;
FontSize = Enum.FontSize.Size24
})
--Local:
Remotes.ShowChatItemUnboxed.OnClientEvent:Connect(function(chatProperties)
game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", chatProperties)
end)
I also tried getting players…
for i, v in pairs(game.Players:GetPlayers()) do
Remotes.ShowChatItemUnboxed:FireClient(v, {
Text = "[Server]: "..Player.Name.." has unboxed ["..ItemModule.GetRarity(ChosenItem).."] ".. ItemModule.GetInfo(ChosenItem).."!";
Color = ItemModule.GetRarityColor(ChosenItem);
Font = Enum.Font.SourceSansBold;
FontSize = Enum.FontSize.Size24
})
end
Is there anything I could do? Thank you in advanced.
Remotes.ShowChatItemUnboxed:FireAllClients({
Text = "[Server]: "..Player.Name.." has unboxed ["..ItemModule.GetRarity(ChosenItem).."] ".. ItemModule.GetInfo(ChosenItem).."!";
Color = ItemModule.GetRarityColor(ChosenItem);
Font = Enum.Font.SourceSansBold;
FontSize = Enum.FontSize.Size24
})
Notice the ;'s, you are supposed to have commas, here is the right code:
Remotes.ShowChatItemUnboxed:FireAllClients({
Text = "[Server]: "..Player.Name.." has unboxed ["..ItemModule.GetRarity(ChosenItem).."] ".. ItemModule.GetInfo(ChosenItem).."!",
Color = ItemModule.GetRarityColor(ChosenItem),
Font = Enum.Font.SourceSansBold,
FontSize = Enum.FontSize.Size24
})
Well, that doesnt make a difference ,
I was really looking on how I could send a message (not to the player localally), but through the server (which everyone could see the message.)
I’d like to point you towards a different way of doing this, if I could.
Introducing the Lua Chat System, which has an absolutely amazing range of customisability and features. With a little bit more hard work, you would be able to obtain this same thing (or better) while keeping the message sending all on the server. Some benefits:
You don’t need to maintain a server-client message sender on your own
Don’t have to rely on the unpredictability of SetCore and its registry
Potentially easier to do after learning the concepts
Canonically correct (afaik this supersedes ChatMakeSystemMessage)
The LCS can create a bot chat speaker so we can have it send out a message as if it were like a regular player. You could even change the name colour if you want. For the sake of keeping things consistent, I’ll keep the name and chat colours the same.
-- This would be near the top with all your declarations and whatnot
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
local DEFAULT_CHANNEL = "All"
local UNBOX_MESSAGE = "%s has unboxed [%s] %s!"
local serverSpeaker = ChatService:AddSpeaker("Server")
-- This part would be where you send the message
local rarity = ItemModule.GetRarity(ChosenItem)
local rarityColor = ItemModule.GetRarityColor(ChosenItem)
local info = ItemModule.GetInfo(ChosenItem)
-- I don't know if there are font ExtraData keys, but try to stay away from them
-- Larger chats consume more chat space, are spammy and are annoying to read
serverSpeaker:SayMessage(UNBOX_MESSAGE:format(Player.Name, rarity, info), "All", {
NameColor = rarityColor,
ChatColor = rarityColor
})