So, I am very new to Lua and I was just wondering about how I show my name on my hud.
Btw, I know I can just do a draw.SimpleText and say my name, although, I want to have it so It detects my name on different servers.
Here is the bit of Code I'm having trouble with
https://files.facepunch.com/forum/upload/319061/f6193aad-4942-4f47-9860-0f024670370e/image.png
I may seem a bit noobish and I apologise if I seem like that. But please help me!
Player/Nick
Player:Nick()
So I just write this where the 'name..' is?
I don't understand what you want your HUD to do.
Player:GetName is just an alias of Player:Nick.
'Nick' is a 'Player' object method, so you need the object of the player you want the nick of. In this case we are running the code on the client so we can simply use the function stored in 'LocalPlayer' to retrieve the client's 'Player' object. Once we have the object we just execute its 'Nick' method...
local ply = LocalPlayer() -- saving the player object in a variable
local nick = ply:Nick() -- using the 'Nick' method to get a string which contains the nickname of that player object
-- now we use the 'SimpleTest' function found inside the 'draw' library to draw the string
draw.SimpleText(nick, "FontFourTest", 10, 150, Color(0, 0, 0))
So I did your method,
local ply = LocalPlayer()
local nick = ply:Nick()
draw.SimpleText(nick, "FontFourTest", 10, 150, Color(100, 0, 0))
draw.RoundedBox(0,7,147,300+6 , 30+6, Color(40,40,40))
draw.RoundedBox(0,10,150,300,30,Color(255,255,255))
end)
and in game it still shows up with nothing, any ideas to fix this?
How did you define the font?
Sorry for the late reply, I saw that my font size was 0. Thank you for the help
Sorry, you need to Log In to post a reply to this thread.