Help with In game name changer(not random name changer)

hi guys,
Ive started learning lua and i need a little help.
Im making a lua so i can change my name ingame because garry broke it :frowning: .
This is the code



function Name()

local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 250,250 )
DermaPanel:SetSize( 500, 50 )
DermaPanel:SetTitle( "Enter a name" )
DermaPanel:ShowCloseButton( true )
DermaPanel:SetVisible( true )
DermaPanel:MakePopup()
 
local DermaText = vgui.Create( "DTextEntry", DermaPanel )
DermaText:SetPos( 20,25 )
DermaText:SetTall( 20 )
DermaText:SetWide( 450 )
DermaText:SetEnterAllowed( true )

DermaText.OnEnter = function()
   LocalPlayer():ConCommand("setinfo name "..DermaText:GetValue() )
    DermaPanel:SetVisible( false )
end
end
end

concommand.Add("name_menu",Name)


I want it to update (Code Below) or refresh every tenth of a second how do i do it?



 LocalPlayer():ConCommand("setinfo name "..DermaText:GetValue() )


When you type something in and press enter like “name” , I want it to update every tenth of a second so my name stays as “name” instead of flashing and going back to my original name.

Thanks,
Roflc0pter

[lua]local doChangeName = true

DermaText.OnEnter = function()
doChangeName = true
DermaPanel:SetVisible( false )
end

function DermaText:Think()
if(!doChangeName) then return end

RunConsoleCommand("setinfo", "name", self:GetValue())
self:NextThink(CurTime() + .1)

end[/lua]

Untested, should work. Unless NextThink doesn’t work on panels.

Lua tags shouldn’t go away after editing.

The name doesent stay after the menu is closed but thanks anyway.Any sollution?

[lua]local hook = hook
local me = LocalPlayer()
me.CurrentName = me:Name()

hook.Add(“Think” , “SetMyName” , function()
RunConsoleCommand(“setinfo” , “name” , me.CurrentName)
end )

local function Name()
local DermaPanel = vgui.Create( “DFrame” )
DermaPanel:SetPos( 250,250 )
DermaPanel:SetSize( 500, 50 )
DermaPanel:SetTitle( “Enter a name” )
DermaPanel:ShowCloseButton( true )
DermaPanel:SetVisible( true )
DermaPanel:MakePopup()

local DermaText = vgui.Create( "DTextEntry", DermaPanel )
DermaText:SetPos( 20,25 )
DermaText:SetTall( 20 )
DermaText:SetWide( 450 )
DermaText:SetEnterAllowed( true )
DermaText.OnEnter = function()
	me.CurrentName = DermaText:GetValue()
	DermaPanel:SetVisible( false )
end

end

concommand.Add(“name_menu”,Name)[/lua]

Thanks Flappie formally Flapjack. :smiley:

i found whats wrong! its where your declaring varibles you didnt make the table me so you cannot use me.currentname

me is set to the player.

[editline]01:53PM[/editline]

[lua]local me = LocalPlayer() [/lua]

yeah, but then its me.currentname but thats a table he is trying to use. why not just do LocalPlayer():Nick() ?

There is nothing wrong with what |FlapJack| has done.

Why call two functions when you can access a variable?