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

Help with a chat GUI, doesn't update text properly?

Asked by 8 years ago

I'm currently developing a chat GUI for my game, it works, but it doesn't, if that makes sense.

Creates the storage (Works)

01local storage = Instance.new("Folder",workspace)
02storage.Name = "Chat"
03 
04local number = 1
05 
06repeat
07    local value = Instance.new("StringValue",workspace.Chat)
08    value.Name = "Line"..number
09    number = number + 1
10    wait()
11until #game.Workspace.Chat:GetChildren() == 7

Change the GUI Text (Doesn't work)

1game.Workspace.Chat.Line1.Changed:connect(function()
2    script.Parent.Line1.Text = game.Workspace.Chat.Line1.Value
3    script.Parent.Line2.Text = game.Workspace.Chat.Line2.Value
4    script.Parent.Line3.Text = game.Workspace.Chat.Line3.Value
5    script.Parent.Line4.Text = game.Workspace.Chat.Line4.Value
6    script.Parent.Line5.Text = game.Workspace.Chat.Line5.Value
7    script.Parent.Line6.Text = game.Workspace.Chat.Line6.Value
8    script.Parent.Line7.Text = game.Workspace.Chat.Line7.Value
9end)

Update the values (Doesn't work)

01local player = game.Players.LocalPlayer
02 
03player.Chatted:connect(function(chatted)
04    game.Workspace:FindFirstChild("Chat").Line2.Value = game.Workspace:FindFirstChild("Chat").Line1.Value
05    game.Workspace:FindFirstChild("Chat").Line3.Value = game.Workspace:FindFirstChild("Chat").Line2.Value
06    game.Workspace:FindFirstChild("Chat").Line4.Value = game.Workspace:FindFirstChild("Chat").Line3.Value
07    game.Workspace:FindFirstChild("Chat").Line5.Value = game.Workspace:FindFirstChild("Chat").Line4.Value
08    game.Workspace:FindFirstChild("Chat").Line6.Value = game.Workspace:FindFirstChild("Chat").Line5.Value
09    game.Workspace:FindFirstChild("Chat").Line7.Value = game.Workspace:FindFirstChild("Chat").Line6.Value
10    game.Workspace:FindFirstChild("Chat").Line1.Value = chatted
11end)

For example, say if I say "Howdy", the gui will change to

1Howdy
2*Blank*
3*Blank*
4*Blank*
5*Blank*
6*Blank*
7*Blank*

But if I then say "Helllo", it will change to

1Helllo
2Howdy
3Howdy
4Howdy
5Howdy
6Howdy
7Howdy

How would I fix this?

2 answers

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

I believe for your UpdateValues script, your setting every chat line aside from line 1 to be the same thing.

Your code:

01local player = game.Players.LocalPlayer
02 
03player.Chatted:connect(function(chatted)
04    game.Workspace:FindFirstChild("Chat").Line2.Value = game.Workspace:FindFirstChild("Chat").Line1.Value
05    game.Workspace:FindFirstChild("Chat").Line3.Value = game.Workspace:FindFirstChild("Chat").Line2.Value
06    game.Workspace:FindFirstChild("Chat").Line4.Value = game.Workspace:FindFirstChild("Chat").Line3.Value
07    game.Workspace:FindFirstChild("Chat").Line5.Value = game.Workspace:FindFirstChild("Chat").Line4.Value
08    game.Workspace:FindFirstChild("Chat").Line6.Value = game.Workspace:FindFirstChild("Chat").Line5.Value
09    game.Workspace:FindFirstChild("Chat").Line7.Value = game.Workspace:FindFirstChild("Chat").Line6.Value --you have set every variable to become line 1, being howdy.
10    game.Workspace:FindFirstChild("Chat").Line1.Value = chatted --and this changes line 1 to be what you chatted, helllo.
11end)

What you can do instead would be assign everything backwards, so every value changes to its respective chat, not just one. Like so:

01local player = game.Players.LocalPlayer
02 
03player.Chatted:connect(function(chatted)
04    game.Workspace:FindFirstChild("Chat").Line7.Value = game.Workspace:FindFirstChild("Chat").Line6.Value
05    game.Workspace:FindFirstChild("Chat").Line6.Value = game.Workspace:FindFirstChild("Chat").Line5.Value
06    game.Workspace:FindFirstChild("Chat").Line5.Value = game.Workspace:FindFirstChild("Chat").Line4.Value
07    game.Workspace:FindFirstChild("Chat").Line4.Value = game.Workspace:FindFirstChild("Chat").Line3.Value
08    game.Workspace:FindFirstChild("Chat").Line3.Value = game.Workspace:FindFirstChild("Chat").Line2.Value
09    game.Workspace:FindFirstChild("Chat").Line2.Value = game.Workspace:FindFirstChild("Chat").Line1.Value
10    game.Workspace:FindFirstChild("Chat").Line1.Value = chatted
11end)
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. :)

Ad
Log in to vote
1
Answered by
3dsonicdx 163
8 years ago

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.

Answer this question