Optiics
|
  |
| Joined: 05 Mar 2013 |
| Total Posts: 1619 |
|
|
| 21 Jul 2013 09:18 PM |
I made this script which contains a function to make text labels. Each text label is named accordingly from "a" to "h". Each text label is suppose to be 0.5 pixels below the other.
you will get what I mean:
script.Parent.Access.MouseButton1Down:connect(function() function console(letter, act, position)
local letter = Instance.new("TextLabel",script.Parent.Console) letter.Name = act letter.Position = position letter.Font = "ArialBold" letter.FontSize = "Size18" letter.TextColor3 = Color3.new(255/255, 255/255, 255/255) letter.TextXAlignment = "Left" end
console(a, "a", UDim2.new(0.03,0,0.95,0)) console(b, "b", a.Position + UDim2.new(0,0,0.05,0)) console(c, "c", b.Position + UDim2.new(0,0,0.05,0)) console(d, "d", c.Position + UDim2.new(0,0,0.05,0)) console(e, "e", d.Position + UDim2.new(0,0,0.05,0)) console(f, "f", e.Position + UDim2.new(0,0,0.05,0)) console(g, "g", f.Position + UDim2.new(0,0,0.05,0)) console(h, "h", g.Position + UDim2.new(0,0,0.05,0))
Here is an Output error I'm getting:
22:17:49.433 - Players.Player1.PlayerGui.ControlPanel.LocalScript:173: attempt to index global 'a' (a nil value) 22:17:49.436 - Script "Players.Player1.PlayerGui.ControlPanel.LocalScript", Line 173 22:17:49.439 - stack end |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2013 09:38 PM |
| Oh, remove letter from it and put a = console(...) b = console(...) etc |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2013 09:52 PM |
| Gah, I am really new to scripting. That looks like japanese to me. I do think he is right though. |
|
|
| Report Abuse |
|
|
Optiics
|
  |
| Joined: 05 Mar 2013 |
| Total Posts: 1619 |
|
|
| 21 Jul 2013 10:06 PM |
The output is referring to this line:
console(b, "b", a.Position + UDim2.new(0,0,0.05,0)) |
|
|
| Report Abuse |
|
|
Optiics
|
  |
| Joined: 05 Mar 2013 |
| Total Posts: 1619 |
|
| |
|
| |
|
Optiics
|
  |
| Joined: 05 Mar 2013 |
| Total Posts: 1619 |
|
|
| 21 Jul 2013 11:27 PM |
| told me what? It made no sense |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2013 11:28 PM |
He said remove the argument letter and make a variable instead
|
|
|
| Report Abuse |
|
|
|
| 21 Jul 2013 11:31 PM |
| Why have a letter parameter when you're just going to override it? It would error because the the letter is nil. |
|
|
| Report Abuse |
|
|
Optiics
|
  |
| Joined: 05 Mar 2013 |
| Total Posts: 1619 |
|
|
| 21 Jul 2013 11:35 PM |
Guys, that isn't even the problem.
I'm still getting this error:
00:34:37.488 - Players.Player1.PlayerGui.ControlPanel.LocalScript:173: attempt to index global 'a' (a nil value) 00:34:37.491 - Script "Players.Player1.PlayerGui.ControlPanel.LocalScript", Line 173 00:34:37.493 - stack end
Here is the script, I defined the line that is causing the error:
script.Parent.Access.MouseButton1Down:connect(function() function console(act, position)
local letter = Instance.new("TextLabel",script.Parent.Console) letter.Name = act letter.Position = position letter.Font = "ArialBold" letter.FontSize = "Size18" letter.TextColor3 = Color3.new(255/255, 255/255, 255/255) letter.TextXAlignment = "Left" end
a = console("a", UDim2.new(0.03,0,0.95,0)) b = console("b", a.Position + UDim2.new(0,0,0.05,0)) -- LINE 173 ERROR c = console("c", b.Position + UDim2.new(0,0,0.05,0)) d = console("d", c.Position + UDim2.new(0,0,0.05,0)) e = console("e", d.Position + UDim2.new(0,0,0.05,0)) f = console("f", e.Position + UDim2.new(0,0,0.05,0)) g = console("g", f.Position + UDim2.new(0,0,0.05,0)) h = console("h", g.Position + UDim2.new(0,0,0.05,0)) |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2013 11:40 PM |
You need to return the letter
Add
return letter
To just before the end |
|
|
| Report Abuse |
|
|
Optiics
|
  |
| Joined: 05 Mar 2013 |
| Total Posts: 1619 |
|
|
| 21 Jul 2013 11:43 PM |
@not
Thanks, it worked.
Can you explain why returning the letter worked tho? |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2013 11:46 PM |
Because it told the script to set a to the return of letter from the function.
Think of it as this: I ask you to go and make me a cake. You go, make the cake (the body of the function) and bring it back to me (the return)
#cannotexplain |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2013 11:47 PM |
| What's the point of even assigning it to a variable? |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2013 11:49 PM |
| You can then do stuff to it for the lulz. |
|
|
| Report Abuse |
|
|