Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I organize objects properly?

You know a chat Gui? How it adds a new frame every time a player chats and removes the top one?

Well I'm trying to do the same thing but opposite, when a player presses a text button it will add there name to a surface Gui list in order of the click.

Example:

IntellectualBeing - Clicks the Text button, IntellectualBeing's name is now on the SurfaceGui list.

Then Jim person clicks the Textbutton, Jim's name is now on the top of the list and IntellectualBeing's is one below the second person that clicked (Jim)

Now if Jen clicks the text button, Jen's name will be on the list replacing Jim's name and IntellectualBeing's name will be replaced with Jims.

Example - continued

Adding a frame

1.IntellectualBeing

Adding a second frame

  1. Jim
  2. IntellectualBeing

Final event, removing/replacing

  1. Jen
  2. Jim

How would I even begin doing this? What should I need to know about?

I already know how to do onmousebutton1 down functions and all of that though.

2 answers

✓ Accepted answer

Hmm... Her's what I think you should do.

Given that the SurfaceGUI does not scroll, there should be a set number of frames that can be visible on the SurfaceGUI at the time. Each frame should have a TextLabel in them. This means that each frame could be updated through scripts.

What I would do is create separate StringValues for each Label. The values should be equal to the Text of the Label it is linked to.

Upon clicking a button, a script can be used that will take the CURRENT StringValues, and use them to replace the CURRENT text within the TextLabels.

Ex)

--Make sure that the script is inside the SurfaceGUI itself; the TextLabels themselves do not have to be in a frame for this to work, but you can add frames, just remember to change the variables a little.


local string1 = script.Parent.StringValue1
local string2 = script.Parent.StringValue2

local label1 = script.Parent.TextLabel1
local label2 = script.Parent.TextLabel2

function getCurrentText() --This will get the text of whatever is currently in the Labels BEFORE adding a name to the list

     string1.Value = label1.Text
     string2.Value = label2.text

end

function updateText(plr)--Change the texts after being updated.
     label1.Text = plr.Name --Adds a new name to the list
     label2.Text = string1.Value --Sets the name of the previous label to itself
     wait(2)
     getCurrentText()
end

script.Parent.MouseButton1Click:connect(updateText)


This is a very rough example and it is not intended to work, but I hope it brings clarity. This is the way I would do it, and I'm sure there are many different ways to solve your problem.

3 comments

0

Aww, I got downvoted for providing a logical way of doing this... I said it was a rough example...

0

I didn't down vote you, I just up-voted you. Yes this did bring up clarity.

0

You understand the concept I'm speaking of right? Using objects and its values to change other objects and their values.

First of all, you need to know two functions before you even think about doing a chat gui.

You need to know these functions:

function onPlayerAdded()

function onChatted()

2 comments

0

I'm not trying to do a chat Gui, I'm trying to make it so when a player clicks a text button there name gets added to a surface Gui in an ordered list.

0

Ah, so sorta like a player list then. Each game comes with it own player list by default unless you remove CoreGuis to get rid of it.

This discussion is preserved as it was. New answers, comments, and votes are closed.