• Determine Player Name
    2 replies, posted
Is there a way to, in script, to determine the name of the player you are currently looking at and place it into a variable? If so what would the code be? And can you provide a sample?
[code]function GetLookatName(ply) local trace = ply:GetEyeTraceNoCursor() if IsValid(trace.Entity) and trace.Entity:IsPlayer() then return trace.Entity:Nick() end return "" end [/code] A function that returns the name of whoever ply is looking at, you can then do [code]local lolname = GetLookatName(myplayer)[/code] to put it in a variable (If you're doing it clientside, just stuff LocalPlayer() instead of "myplayer" to the function)
Got it, thanks!
Sorry, you need to Log In to post a reply to this thread.