Derma menu button SetText help

Hey guys, stupid question here but could someone help me with this peace of code:

GetID.DoClick = function() Steam:SetText( "SteamID: ", ply:SteamID() ) SteamNick:SetText( "UserName: ", ply:GetName() ) end

It seems to only set the "SteamID: " and "UserName: " text into the text boxes, I believe its got something to do with the function() just not sure what it is I need to place into the ().


Did you define ply anywhere? You can always use LocalPlayer() since it’s clientside code.

Okay I shall give this a try, Brb.

[editline]8th February 2013[/editline]

I tried

GetID.DoClick = function(ply) Steam:SetText( "SteamID: ", ply:SteamID() ) SteamNick:SetText( "UserName: ", ply:GetName() ) end

And it is giving me the error of :

[ERROR] RunString:548: attempt to call method 'SteamID' (a nil value)
  1. DoClick - RunString:548
   2. unknown - lua/vgui/dlabel.lua:206

It doesn’t know what ply is because you set it as a function parameter.
Did you try LocalPlayer() instead of ply?

Place LocalPlayer() as the function()?

No… Use LocalPlayer() instead of ply.
Example: LocalPlayer():SteamID()

Oh I shall try that now.

[editline]8th February 2013[/editline]

That gives me another error, the steamID works fine if I remove the "SteamID: " but I want it to be like SteamID: STEAM:XXXXXX and its the same with the Username

Steam:SetText("SteamID: " … LocalPlayer():SteamID())
SteamNick:SetText("UserName: " … LocalPlayer():GetName())

Thank you I shall test it

[editline]8th February 2013[/editline]

Works perfect! Thank you for all your help ms333 :slight_smile: