• DLabel Set Text
    4 replies, posted
So I am trying to get my DLabel to show something that I have defined. [CODE]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) [/CODE] I have tried and failed doing something with this: [URL="https://wiki.garrysmod.com/page/Global/tostring"]Click Here[/URL] As it says: [CODE][ERROR] lua/filename.lua:25: bad argument #1 to 'SetText' (string expected, got nil) 1. SetText - [C]:-1 2. unknown - lua/filename.lua:25 [/CODE] [I]Line 25 is different for me and you[/I] 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
[QUOTE=Skere_;51274548]You shouldn't make a function for this (especially not a global one) Simply call LocalPlayer():SteamID() in SetText[/QUOTE] Thanks so much I am new to lua (1 week in), Thanks Again
[QUOTE=Mrdbuffalo;51274562]Thanks so much I am new to lua (1 week in), Thanks Again[/QUOTE] 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()
[QUOTE=Its Pawsative;51276053]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()[/QUOTE] Thanks for clearing it up ;)
Sorry, you need to Log In to post a reply to this thread.