I just started Lua, and it’s going kinda well so far.
I’m reading the GMOD Wiki Lua tutorials.
I made this script
[lua]Name=PointWezt
myName=WeztPoint
Msg(“Hello “…myName…”!/n”)
Msg(“How are you today “…Name…”?/n”)
Msg(“Hope you’re having fun, “…myName…”!/n”)
Msg(“If you aren’t having fun “…Name…”, go play another game!/n”)[/lua]
And it’s supposed to write something in console, but i get this error message "
Running script multiplevariables.lua…
multiplevariables.lua:3: attempt to concatenate global ‘myName’ (a nil value)"
So, please help me.
I would prefer an explanation, not just a solution. Thanks in advance!
By the way, what’s that code tag called? It’s not
[/ code]. You know, the one with the numbers on the side.
Name and myName are holding nil values because you forgot to put PointWezt and WeztPoint in quotation marks to make them strings.
[lua]local Name = “PointWezt”
local myName = “WeztPoint”
Msg(“Hello “…myName…”!/n”)
Msg(“How are you today “…Name…”?/n”)
Msg(“Hope you’re having fun, “…myName…”!/n”)
Msg(“If you aren’t having fun “…Name…”, go play another game!/n”)[/lua]
also, I suggest making them local so they are only accessible from this file.
[lua]local age = 14
local age1 = 19
if age < 15 then
Msg ("Sorry Wezt, you gotta be atleast 15. You’re only “…age…”. Come back when you are over 15.
“)
elseif age1 > 18 then
Msg (“You’re over 18. In fact, you are “…age1…”. Too bad, huh?
“)
else
Msg (“Welcome to High School! You’re over”…age…”, and under”…age1…”. That way you can enter High School!
")
end[/lua]
Made another code, don’t know if it will work.
I read the tutorial on GMOD wiki.