I'm creating a custom chat and I'm having lots of issues, for starters the chat messages is not showing up for all the players. I just don't really know how I should do this which is why I was wondering if someone more experience with lua than me could improve on what I have already made
The Current code, found in a localscript in startergui:
repeat wait() until game.Players.LocalPlayer
wait(1)
local StarterGui = game:GetService('StarterGui')
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
---------------------------------------------------------------------------
--Variables
---------------------------------------------------------------------------
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
_G.moving = false
---------------------------------------------------------------------------
--Functions
---------------------------------------------------------------------------
function createChatLine()
local textlabel = Instance.new("TextLabel")
textlabel.BackgroundTransparency = 1
textlabel.TextXAlignment = "Left"
textlabel.Size = UDim2.new(1,0,.1,0)
textlabel.Position = UDim2.new(0,0,0.76,0)
textlabel.Name = "chatbar"
return textlabel
end
---------------------------------------------------------------------------
--Global Functions
---------------------------------------------------------------------------
function _G.addMessage(player, chat)
if (_G.moving == true) then
repeat wait() until _G.moving == false
end
_G.moving = true
print(_G.moving)
for _, chatbars in pairs (script.Parent:GetChildren()) do
if (chatbars.ClassName == "TextLabel") then
chatbars:TweenPosition(UDim2.new(0,0,chatbars.Position.Y.Scale-.1,0), "Out", "Quad", .5, true)
wait()
end
end
local chatbar = createChatLine()
chatbar.Parent = script.Parent
chatbar.Text = player.Name .. ": " .. chat
script.Parent.ChatBar.Text = "Click Here to Chat"
_G.moving = false
end
---------------------------------------------------------------------------
--Events
---------------------------------------------------------------------------
Mouse.KeyDown:connect(function(Key)
if (Key == string.char(13)) then
_G.addMessage(Player, script.Parent.ChatBar.Text)
end
end)

2 comments
First try debugging it. Put print statements at certain areas to detect if they're running. Check the gui's to make sure the label is not just hidden. Then if all else fails, get back to us.
It's running fine but my main problem is what is a proper way to send a message to multiple people with my global function for creating a message. The global function is suppose to be called for everyone but it is not