Make the alpha fade or not when the player is in a distance ?

All is in the Title.

I want to fade out a 3d2d thing when the player isn’t in range to read it…

help plz

This really shouldn’t have needed its own thread, or really even a post…

It’s pretty basic in terms of math to do, and can be as easy as

255 - math.min(Distance, 255)

Where’s distance is how far away the player is. You could achieve different results by playing around with values and what not, not really one answer to give.

This function (

math.Remap) will help you no doubt, as it allows you to do fancy stuff like this.

ENT.MaxAlphaAtDistance = 50 – Distance at which alpha = 255
ENT.MaxAlphaAtDistance = 500 – Distance at which alpha = 0

function ENT:GetAlphaValueMyPanel( )

return math.Clamp(
		self:GetPos():Distance( LocalPlayer():GetPos() ),
		255 ),


This allows you to start the distance at which the alpha is 255 to a non-zero distance. The code isn’t proof read so consider it pseudocode for the moment, but it should give you an idea at least.