Just to give you a clip of what I mean, here's what I put down.
1 | function OnClick() |
2 | records.Visible = true |
3 | records.Title = "History for " ..player.Name.. |
4 | end |
Whenever I attempt to use that it errors with this: Expected identifier, got 'end' I did described what player was and all that was described but I can't get why it errors.
I did include additional things but only this part since it was the only part of the script that error'ed.
You have an extra ..
at the end of the line.
..
concatenates two strings -- one to the left and one to the right -- it "expected" another string to the right ('identifier'), but it got an "end" (on the next line)
Just
1 | records.Title = "History for " .. player.Name |
will show "History for BlueTaslem", for instance.
This is a good reason it's standard practice to put spaces around everything. You'll notice things like the trailing ..
much more easily.
1 | local player = game.Players.LocalPlayer -- ADD THIS |
2 | function OnClick() |
3 | records.Visible = true |
4 | records.Title = "History for " ..player.Name.. |
5 | end |
First things first, you need to use the MouseButton1Click event which fires when you left click
on the gui. I did this on the last line.
On the first three lines, I made variables which you will need to make this work. Change the variables parenting and such to be correct.
Now in the function
I made the records gui visible and changed it's Text property to be the players name. Don't put two extra dots if you aren't going to Concate anymore.
You can read more on Concatenation here
1 | local player = script.Parent.Parent |
2 | local gui = script.Parent:WaitForChild( "ScreenGui" ):WaitForChild( "Gui" ) |
3 | local records = script.Parent:WaitForChild( "ScreenGui" ):FindFirstChild( "records" ) |
4 | function OnClick() |
5 | records.Visible = true |
6 | records.Text = "History for " ..player.Name |
7 | end |
8 |
9 | gui.MouseButton 1 Click:connect(OnClick) |