I am making a chat gui and everything works perfectly but when 2 players spam the chat can overlap? Any way to fix this?
print("New Server")
--Variables--
Settings = {
Enabled = true --Chat Enabled--
,ServerResponseColor = "Cyan" --Server Text--
,PlayerChatColor = "White" --Color players text is--
,ShowRankInGroup = {false, 7} --Example Goldgrilz7 [Leader]: Hey guys!--
,Admins = {"Goldgrilz7", 7}
}
--Only change anything below this line if you know what you're doing--
function cleantable() --Wipes clean all chat history auto updates players--
print("Cleaning Table")
gui = script.Chat.Chat:GetChildren()
for i = 1, #gui do
if gui[i].Name == "Chat_Bar"
then
gui[i]:remove()
end
for i, v in pairs(game.Players:GetChildren()) do
if v.PlayerGui:FindFirstChild("Chat") ~= nil
then
v.PlayerGui:FindFirstChild("Chat"):remove()
end
end
end
end
cleantable()
if Settings.Enabled == false
then
script.Chat.HideChat.Disabled = true
end
function ac(player) --Admin check
a = false
for i = 1, #Settings.Admins do
if Settings.Admins[i] == player
then
a = true
end
end
return a
end
if Settings.Enabled == true
then
script.Chat.HideChat.Disabled = true
function onchat(msg, player)
wait(.05)
admincheck = ac(player.Name)
if msg:sub(1,3):lower() == ";sm" and admincheck == true
then
_G.respond(msg:sub(5))
else if msg:sub(1,10):lower() == ";showranks" and msg:sub(11,13) ~= "off" and admincheck == true
then
Settings.ShowRankInGroup[1] = true
_G.respond("Enabled Visual Chat Rank")
else if msg:sub(1,12):lower() == ";showranksoff" and admincheck == true
then
Settings.ShowRankInGroup[1] = false
_G.respond("Disabled Visual Chat Rank")
else if msg:sub(1,8):lower() == ";groupid" and admincheck == true
then
Settings.ShowRankInGroup[2] = tonumber(msg:sub(9))
_G.respond("Changed Group To"..msg:sub(9))
else
print(msg, player)
p = game.Players:GetChildren()
gui = script.Chat
gui.Chat.Update.Disabled = false
message = script.Chat_Bar:Clone()
message.Text = player.Name..": "..msg
message.TextColor3 = BrickColor.new(Settings.PlayerChatColor).Color
if Settings.ShowRankInGroup[1] == true
then
message.Text = player.Name.." ["..player:GetRoleInGroup(Settings.ShowRankInGroup[2]).."]: "..msg
end
message.Parent = gui.Chat
game:GetService("Debris"):AddItem(message, 120)
for i = 1, #p do
wait(.01)
if p[i]:FindFirstChild("PlayerGui") ~= nil
then
if p[i].PlayerGui:FindFirstChild("Chat") ~= nil
then
p[i].PlayerGui.Chat.Chat.LUpdate.Disabled = false
message = script.Chat_Bar:Clone()
message.TextColor3 = BrickColor.new(Settings.PlayerChatColor).Color
message.Text = player.Name..": "..msg
if Settings.ShowRankInGroup[1] == true
then
message.Text = player.Name.." ["..player:GetRoleInGroup(Settings.ShowRankInGroup[2]).."]: "..msg
end
game:GetService("Debris"):AddItem(message, 120)
message.Parent = p[i].PlayerGui.Chat.Chat
message.TextTransparency = 1
message.TextStrokeTransparency = 1
end
end
end
end
end
end
end
end
game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(msg) onchat(msg, player) end)
_G.respond(player.Name.." Has Joined")
end)
while true do
wait()
for i, v in pairs(game.Players:GetChildren()) do
if v.PlayerGui:FindFirstChild("Chat") == nil
then
clone = script.Chat:Clone()
clone.Parent = v.PlayerGui
end
end
end
end
