Help with FilteringEnabled/Chat gui?
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)
01 | player.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 |
12 | v.Name = "line" .. tostring ( tonumber (LineNumber) + 1 ) |
13 | v.Position = v.Position - UDim 2. new( 0 , 0 , 0 , 20 ) |
17 | newchatline = Instance.new( "TextLabel" ,player:WaitForChild( "PlayerGui" ).chatter.textboxy) |
19 | newchatline.Text = player.Name.. ": " ..message |
21 | newchatline.Text = "System Message: " ..message |
23 | newchatline.Size = UDim 2. new( 1 , 0 , 0 , 20 ) |
24 | newchatline.Position = UDim 2. new( 0 , 0 , 1 ,- 20 ) |
25 | newchatline.Font = "SourceSansBold" |
26 | newchatline.TextColor 3 = player:FindFirstChild( "color" ).Value.Color |
27 | newchatline.TextStrokeTransparency = 0 |
28 | newchatline.BackgroundTransparency = 1 |
29 | newchatline.BorderSizePixel = 0 |
30 | newchatline.FontSize = "Size18" |
31 | newchatline.TextXAlignment = "Left" |
32 | newchatline.TextYAlignment = "Top" |
33 | newchatline.ClipsDescendants = true |
34 | newchatline.Name = "line1" |
35 | game:GetService( "ReplicatedStorage" ).Chatted:InvokeServer(message) |
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?
01 | local PG = player:WaitForChild( "PlayerGui" ) |
02 | repeat wait() until PG:FindFirstChild( "chatter" ) |
03 | repeat wait() until PG.chatter:FindFirstChild( "textboxy" ) |
04 | for 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 |
12 | v.Name = "line" .. tostring ( tonumber (LineNumber) + 1 ) |
13 | v.Position = v.Position - UDim 2. new( 0 , 0 , 0 , 20 ) |
17 | if v.Name ~ = player.Name then |
18 | newchatline = Instance.new( "TextLabel" ,v:WaitForChild( "PlayerGui" ).chatter.textboxy) |
20 | newchatline.Text = player.Name.. ": " .. message |
22 | newchatline.Text = "System Message: " .. message |
24 | newchatline.Size = UDim 2. new( 1 , 0 , 0 , 20 ) |
25 | newchatline.Position = UDim 2. new( 0 , 0 , 1 ,- 20 ) |
26 | newchatline.Font = "SourceSansBold" |
27 | newchatline.TextColor 3 = player:FindFirstChild( "color" ).Value.Color |
28 | newchatline.TextStrokeTransparency = 0 |
29 | newchatline.BackgroundTransparency = 1 |
30 | newchatline.BorderSizePixel = 0 |
31 | newchatline.FontSize = "Size18" |
32 | newchatline.TextXAlignment = "Left" |
33 | newchatline.TextYAlignment = "Top" |
34 | newchatline.ClipsDescendants = true |
35 | newchatline.Name = "line1" |
38 | local Parent 2 = game:GetService( "StarterGui" ).chatter.textboxy |
39 | for i,v in pairs (Parent 2 :GetChildren()) do |
40 | if v.Name:sub( 1 , 4 ):lower() = = "line" then |
41 | local LineNumber = v.Name:sub( 5 ) |
42 | if LineNumber = = "9" then |
45 | v.Name = "line" .. tostring ( tonumber (LineNumber) + 1 ) |
46 | v.Position = v.Position - UDim 2. new( 0 , 0 , 0 , 20 ) |
51 | newchatline:Clone().Parent = game:GetService( "StarterGui" ).chatter.textboxy |