I am making a chat gui and everything works perfectly but when 2 players spam the chat can overlap? Any way to fix this?
001 | print ( "New Server" ) |
002 | --Variables-- |
003 | Settings = { |
004 | Enabled = true --Chat Enabled-- |
005 | ,ServerResponseColor = "Cyan" --Server Text-- |
006 | ,PlayerChatColor = "White" --Color players text is-- |
007 | ,ShowRankInGroup = { false , 7 } --Example Goldgrilz7 [Leader]: Hey guys!-- |
008 | ,Admins = { "Goldgrilz7" , 7 } |
009 | } |
010 |
011 | --Only change anything below this line if you know what you're doing-- |
012 |
013 | function cleantable() --Wipes clean all chat history auto updates players-- |
014 | print ( "Cleaning Table" ) |
015 | gui = script.Chat.Chat:GetChildren() |
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?
Well, I made a chat once and I had the same problem. To fix it, I made a debounce. It's something like this:
01 | local ready = true --the debounce |
02 |
03 | function chat() --function that adds messages to the chat |
04 | ready = false |
05 | --chat code |
06 | ready = true |
07 | end |
08 |
09 | player.Chatted:connect( function () --you can use a named function, but I'm using an anonymous function |
10 | repeat wait( 0 ) until ready --a repeat loop; if ready (the debounce) is false, it will keep waiting one frame (wait(0)) until ready is true again |
11 | chat() --call your chat function |
12 | end ) |
So basically, the ready
variable will always be true until the chat function is called. ready
will remain false until the call function finishes.
It might be different for your chat, but that is how I prevented 'chat-overlap' in my custom chat.
Hoped I helped.
~coo1o
If you are wanting to make it so when there is one gui already open, and someone trys to reopen it the current gui goes away and the new one appears, here is the solution
Name = "GUINAMEINHERE" if player.PlayerGui:FindFirstChild(Name) then game.Debris:AddItem(player.PlayerGui[Name],0)