I'm currently developing a chat GUI for my game, it works, but it doesn't, if that makes sense.
Creates the storage (Works)
01 | local storage = Instance.new( "Folder" ,workspace) |
02 | storage.Name = "Chat" |
03 |
04 | local number = 1 |
05 |
06 | repeat |
07 | local value = Instance.new( "StringValue" ,workspace.Chat) |
08 | value.Name = "Line" ..number |
09 | number = number + 1 |
10 | wait() |
11 | until #game.Workspace.Chat:GetChildren() = = 7 |
Change the GUI Text (Doesn't work)
1 | game.Workspace.Chat.Line 1. Changed:connect( function () |
2 | script.Parent.Line 1. Text = game.Workspace.Chat.Line 1. Value |
3 | script.Parent.Line 2. Text = game.Workspace.Chat.Line 2. Value |
4 | script.Parent.Line 3. Text = game.Workspace.Chat.Line 3. Value |
5 | script.Parent.Line 4. Text = game.Workspace.Chat.Line 4. Value |
6 | script.Parent.Line 5. Text = game.Workspace.Chat.Line 5. Value |
7 | script.Parent.Line 6. Text = game.Workspace.Chat.Line 6. Value |
8 | script.Parent.Line 7. Text = game.Workspace.Chat.Line 7. Value |
9 | end ) |
Update the values (Doesn't work)
01 | local player = game.Players.LocalPlayer |
02 |
03 | player.Chatted:connect( function (chatted) |
04 | game.Workspace:FindFirstChild( "Chat" ).Line 2. Value = game.Workspace:FindFirstChild( "Chat" ).Line 1. Value |
05 | game.Workspace:FindFirstChild( "Chat" ).Line 3. Value = game.Workspace:FindFirstChild( "Chat" ).Line 2. Value |
06 | game.Workspace:FindFirstChild( "Chat" ).Line 4. Value = game.Workspace:FindFirstChild( "Chat" ).Line 3. Value |
07 | game.Workspace:FindFirstChild( "Chat" ).Line 5. Value = game.Workspace:FindFirstChild( "Chat" ).Line 4. Value |
08 | game.Workspace:FindFirstChild( "Chat" ).Line 6. Value = game.Workspace:FindFirstChild( "Chat" ).Line 5. Value |
09 | game.Workspace:FindFirstChild( "Chat" ).Line 7. Value = game.Workspace:FindFirstChild( "Chat" ).Line 6. Value |
10 | game.Workspace:FindFirstChild( "Chat" ).Line 1. Value = chatted |
11 | end ) |
For example, say if I say "Howdy", the gui will change to
1 | Howdy |
2 | *Blank* |
3 | *Blank* |
4 | *Blank* |
5 | *Blank* |
6 | *Blank* |
7 | *Blank* |
But if I then say "Helllo", it will change to
1 | Helllo |
2 | Howdy |
3 | Howdy |
4 | Howdy |
5 | Howdy |
6 | Howdy |
7 | Howdy |
How would I fix this?
I believe for your UpdateValues script, your setting every chat line aside from line 1 to be the same thing.
Your code:
01 | local player = game.Players.LocalPlayer |
02 |
03 | player.Chatted:connect( function (chatted) |
04 | game.Workspace:FindFirstChild( "Chat" ).Line 2. Value = game.Workspace:FindFirstChild( "Chat" ).Line 1. Value |
05 | game.Workspace:FindFirstChild( "Chat" ).Line 3. Value = game.Workspace:FindFirstChild( "Chat" ).Line 2. Value |
06 | game.Workspace:FindFirstChild( "Chat" ).Line 4. Value = game.Workspace:FindFirstChild( "Chat" ).Line 3. Value |
07 | game.Workspace:FindFirstChild( "Chat" ).Line 5. Value = game.Workspace:FindFirstChild( "Chat" ).Line 4. Value |
08 | game.Workspace:FindFirstChild( "Chat" ).Line 6. Value = game.Workspace:FindFirstChild( "Chat" ).Line 5. Value |
09 | game.Workspace:FindFirstChild( "Chat" ).Line 7. Value = game.Workspace:FindFirstChild( "Chat" ).Line 6. Value --you have set every variable to become line 1, being howdy. |
10 | game.Workspace:FindFirstChild( "Chat" ).Line 1. Value = chatted --and this changes line 1 to be what you chatted, helllo. |
11 | end ) |
What you can do instead would be assign everything backwards, so every value changes to its respective chat, not just one. Like so:
01 | local player = game.Players.LocalPlayer |
02 |
03 | player.Chatted:connect( function (chatted) |
04 | game.Workspace:FindFirstChild( "Chat" ).Line 7. Value = game.Workspace:FindFirstChild( "Chat" ).Line 6. Value |
05 | game.Workspace:FindFirstChild( "Chat" ).Line 6. Value = game.Workspace:FindFirstChild( "Chat" ).Line 5. Value |
06 | game.Workspace:FindFirstChild( "Chat" ).Line 5. Value = game.Workspace:FindFirstChild( "Chat" ).Line 4. Value |
07 | game.Workspace:FindFirstChild( "Chat" ).Line 4. Value = game.Workspace:FindFirstChild( "Chat" ).Line 3. Value |
08 | game.Workspace:FindFirstChild( "Chat" ).Line 3. Value = game.Workspace:FindFirstChild( "Chat" ).Line 2. Value |
09 | game.Workspace:FindFirstChild( "Chat" ).Line 2. Value = game.Workspace:FindFirstChild( "Chat" ).Line 1. Value |
10 | game.Workspace:FindFirstChild( "Chat" ).Line 1. Value = chatted |
11 | end ) |
12 |
13 | --Here, we can set one line to be the previous line, thus moving text down, instead of changing all the text to be the same thing. |
As for your Changing Text script, it appears to be working fine. You say "Howdy", and line 1 becomes "Howdy".
If anything needs clarifying, please let me know and I'll do my best to make it clear. Hope this helps. :)
You are changing the text in the wrong order.
So basically - they all say Howdy because you change Line 2 into Line 3 - then afterwards Line 3 into Line 4.
What you need to do is change Line 9 into nothing, Line 8 into 9, and move DOWNWARDS rather than UPWARDS.