Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with FilteringEnabled/Chat gui?

Asked by 10 years ago

Hello guys I'm back, this time with a slightly longer question, I am trying to make a filtering enabled chat gui but am having an issue. The message is meant to be made locally, then through a remote-event is cloned onto everyone's client other than the senders, here is the code:

Local code: (creates gui for the sender, successfully moves all other messages up one)

01player.Chatted:connect(function(message)
02    local PG  = player:WaitForChild("PlayerGui")
03    repeat wait() until PG:FindFirstChild("chatter")
04    repeat wait() until PG.chatter:FindFirstChild("textboxy")
05    local Parent = player:WaitForChild("PlayerGui").chatter.textboxy
06    for i,v in pairs(Parent:GetChildren()) do
07        if v.Name:sub(1,4):lower() == "line" then
08            local LineNumber = v.Name:sub(5)
09            if LineNumber == "9" then
10                v:Destroy()
11            else
12                v.Name = "line"..tostring(tonumber(LineNumber) + 1)
13                v.Position = v.Position - UDim2.new(0,0,0,20)
14            end
15        end
View all 36 lines...

Server script: Message clones onto everyone's screens other than sender as intended, although it DOES NOT move the local message up one, for example if I send 3 messages "msg1""msg2""msg3" and then someone else sent one ("msg4") it would just overlap with message 3 and not send it up one rung of the ladder, if another person was to send a message after that it would move msg4 up but the local mesages would remain in place, I don't really understand this! From what I gather it is because the server script cannot access the local gui because of filtering enabled and therefore cannot move it up as it does not exist! The only way I can think of getting around this is by make everything client side, but I really wanted to do it this way in order to reduce lag!

Any ideas?

01local PG  = player:WaitForChild("PlayerGui")
02repeat wait() until PG:FindFirstChild("chatter")
03repeat wait() until PG.chatter:FindFirstChild("textboxy")
04for i,v in pairs(game:GetService("Players"):GetPlayers()) do
05    local Parent = v:WaitForChild("PlayerGui").chatter.textboxy
06    for i,v in pairs(Parent:GetChildren()) do
07        if v.Name:sub(1,4):lower() == "line" then
08            local LineNumber = v.Name:sub(5)
09            if LineNumber == "9" then
10                v:Destroy()
11            else
12                v.Name = "line"..tostring(tonumber(LineNumber) + 1)
13                v.Position = v.Position - UDim2.new(0,0,0,20)
14            end
15        end
View all 52 lines...

1 answer

Log in to vote
1
Answered by 10 years ago

You could make a queue in the client. When it receives a message from the server, add it to the back of the queue. Have a LocalScript work through the queue from the start of the queue, generating TextLabels for the messages. When the LocalScript moves to the next message in the queue, move all the TextLabels up that have already been created.

Ad

Answer this question