Hi, i'm making a panel where it lists all players on the server and you can click on their name and it will bring up the player's playermodel. The problem i'm having is that If the player's name is clicked more than once/a new players name is clicked, its overlapping the player model that already exists.
I've tried checking if the panel is already valid with Panel:IsValid() but then its removing the playermodel as soon as it is spawned.
for k, v in pairs( player.GetAll() ) do
local DLabel = DScrollPanel:Add( "DButton" )
DLabel:SetText( v:Nick())
DLabel:Dock( TOP )
DLabel:DockMargin( 10, 5, 0, 0 )
DLabel:SetTextColor( Color( 230,230,230, 255 ) )
DLabel:SetFont("NPC_Bail_ButtonLabel")
DLabel.Paint = function( self, w, h )
if self:IsDown() then
draw.RoundedBox(0, 0, 0, w - 10, h, Color(0, 116, 217,255))
else
draw.RoundedBox(0, 0, 0, w - 10, h, Color(0, 106, 207,255))
end
end
function DLabel:DoClick()
local Playermodel = vgui.Create("DPanel", mainMenu)
function Playermodel.Paint(self, w, h)
draw.RoundedBox(0, 0, 0, w, h, Color(255, 0, 0, 100))
end
Playermodel:SetPos(355, 70) -- This is the background to where the model is spawned
Playermodel:SetSize(200, 200)
local icon = vgui.Create( "DModelPanel", Playermodel )
icon:SetSize( 200, 200 )
icon:SetModel( v:GetModel() ) -- actual spawning of playermodel
function icon:LayoutEntity( Entity ) return end
end
end
Any help is appreciated. Thanks
Is there any reason you couldn't have the player model DPanel and DModelPanel already created outside of the DoClick() method?
This would prevent creating a new DPanel and DModelPanel when clicking someone, and replace the DoClick() method with the following,
(Playermodel.icon being the DModelPanel)
Playermodel.icon:SetModel(v:GetModel())
Playermodel:Show()
Sorry, you need to Log In to post a reply to this thread.