Hiya, so I am the developer of the upcoming Chatting App, JustChat. Now, there is an issue which seems pretty weird to me.
For some reason, the chat message I am sending, is displaying on my own client but not on the other one, instead telling me in the console ‘PlayerGui is not a valid member of Players.JCTestingAccount’ and vice versa
Here is an image of it showing both clients:
This is all the code I use for sending it
After enter is pressed, it fires the Text to the server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SendChatMessage = ReplicatedStorage:WaitForChild("SendChatMessage")
local LPlayer = game.Players.LocalPlayer
local textBox = script.Parent
script.Parent.FocusLost:Connect(function(enterPressed)
if enterPressed then
SendChatMessage:FireServer(textBox.Text)
end
end)
Once received, the server then filters the message using game.Chat:FilterStringForBroadcast()
(This is mandatory or else ROBLOX might moderate my game).
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SendChatMessage = ReplicatedStorage:WaitForChild("SendChatMessage")
SendChatMessage.OnServerEvent:Connect(function(player, message : string)
local FilteredMessage = game.Chat:FilterStringForBroadcast(message, player)
SendChatMessage:FireAllClients(player, FilteredMessage)
end)
Then the server fires the RemoteEvent back to all clients, who in term makes the message visible to everyone
game.ReplicatedStorage.SendChatMessage.OnClientEvent:Connect(function(player : Player, message : string)
local SenderName = player.Name
local SenderAvatar = game.Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150)
local ChatMessageTemplateClone = player.PlayerGui.UI.Main.Chat.ChatMessages.UIListLayout.ChatMessageTemplate:Clone()
if SenderName == "Hauber_RBLX" then
ChatMessageTemplateClone.Sender.Text = '<b><font color="#6190ff">[DEV]</font> <font color="#e25f5f">[CHAT MOD]</font></b> '..SenderName
else
ChatMessageTemplateClone.Sender.Text = SenderName
end
ChatMessageTemplateClone.MessageContent.Text = message
ChatMessageTemplateClone.Avatar.Image = SenderAvatar
ChatMessageTemplateClone.Name = SenderName
ChatMessageTemplateClone.Parent = player.PlayerGui.UI.Main.Chat.ChatMessages
player.PlayerGui.UI.Main.Chat.ChatMessageInput.Text = ""
end)
Does anyone know why the hell it shows the message on the own client, but not on the other client?