DLabel Set Text

So I am trying to get my DLabel to show something that I have defined.


local playersteamid
function PlayerSteamID( ply )
	playersteamid = ply.SteamID
end

local frame = vgui.Create("DFrame")
frame:SetSize( ScrW() * 0.500, ScrH() * 0.500 )
frame:Center()
frame:MakePopup()
frame:SetTitle("")
frame:SetVisible(true)
frame.Paint = function (self, w, h)
	draw.RoundedBox(15,0,0,w,h,Color(38,173,229,255))
end

local label = vgui.Create("DLabel", frame)
label:SetText(playersteamid)
label:SetPos(145,-130)
label:SetSize(300,300)


I have tried and failed doing something with this: Click Here
As it says:


[ERROR] lua/filename.lua:25: bad argument #1 to 'SetText' (string expected, got nil)
  1. SetText - [C]:-1
   2. unknown - lua/filename.lua:25


Line 25 is different for me and you

So any help would be appreciated

You shouldn’t make a function for this (especially not a global one)

Simply call LocalPlayer():SteamID() in SetText

Thanks so much I am new to lua (1 week in),
Thanks Again

Not sure if you care, but if you want to know the actual error, it’s because you set the string as playersteamid, and never called the function, you should of done :SetText(PlayerSteamID(LocalPlayer())), and playersteamid = ply.SteamID should be playersteamid = ply:SteamID()

Thanks for clearing it up :wink: