Is there a way I could possibly input a value into a gui for instance I am wanting to make it where you gather items and the value would change. If so I would enjoy the helpful advice
First, depending on how this functions, I would add a script or a localscript in the GUI/Textbox so the text can be accessed no matter where the GUI happens to be located. So, lets get started.
Now lets say I have an acorn hidden somewhere around the map, touching the acorn gives its collector a point. Well to display those points in the form of a GUI to that person, I would need to have a GUI in that player's PlayerGUI. I could make a script and add this in manually, but we can save time by just making a template in the StarterGUI. After our GUI has been set up put a TextBox in the Frame. This will be what displays our value.
Now onto the coding, which really isn't all that complicated. I'll start by putting a Localscript in the Textbox, and adding part in the workspace and name it 'acorn'. To reference this 'acorn' part in my localscript I can start by making a variable:
acrn = workspace.acorn
This 'acrn' is what's called a Variable. Variables are basically our code names for whatever we are referencing, in this case it's our 'acorn' part. You can change acrn to whatever you want, but for namesake I'm calling it acrn. We also need to reference out Score, text, and text box. I'll set that up for timesake.
So we have our Variable, but what does that do for us? We need a function, and something to call the function.
acrn = workspace.acorn Box = script.Parent Text = Box.Text Score = 0 Text = Score acrn.Touched:connect(function() -- Connection line and function, will call when acrn is touched. -- Stuff goes here end)
Now all we need is something to give the person who found it a point. Our finished script should look like this:
acrn = workspace.acorn Box = script.Parent Text = Box.Text Score = 0 Text = Score acrn.Touched:connect(function() Score = Score + 1 Text = Score wait(2) end)
And that's about it. If you have any questions let me know. :)