Is there a way to make billboardguis fade out?

So basically what I have is custom overhead guis that say the player name and has a health bar but i was wondering if there was a way to make it so that like when they dissapear (by max distance) they fade out instead of just dissapear like the default roblox names over the players head

This requires some linear interpolation where you check the distance between the player and you and then interpolate a certain interval depending on max distance and then change the transparency accordingly. RunService will be used on events like Stepped or RenderStepped.

Break that down so its easier to understand

You can use TweenService to create a tween the transparency for the billboard gui whenever the player is outside of the gui’s bounds, as well as when a player enters the gui’s bounds. Tweens override each other so it shouldn’t be a problem.

I’m just wondering how I would do that because I don’t know how to use stepped or renderstepped or what it means

I wouldn’t count it on TweenService as there are inconsistency issues if the player runs in and out of the boundary, unless you have overriding methods to the code.

  • Distance check by Player:DistanceFromCharacter()
  • Interpolate the value of x / maxDistance as alpha
  • Looping this by RunService.Stepped:Connect()

As from what Operatik said where you use events like stepeed or renderstepped

what im trying to tell you is if you can tell me what you said in a way thats easier for me to understand because im not too advanced of a scripter

for example am i supposed to make a script that checks if a player is near another player then made it fade in or out

Yeah but my question is how the renderstepped works or what its supposed to do

RenderStepped is an event that is fired right before each frame is about to be rendered.

so when you say think i think how far a client can see something such as with graphics quality

To further explain what RunService’s Heartbeat, Stepped and RenderStepped are:

They are included in the Task Scheduler, responsible for most of the game’s replication and rendering in seemingly real-time.

It is actually a lot more simple when I mention the necessary components required to achieve the aforementioned effect.

Additionally, BindToRenderStep seems more favorable than the events themselves.

I find it kind of stupid people are talking about RunService. I think you’re talking about detecting the distance right? There’s a thing called .Magnitude which gives you some info about how far away stuff is. Might wanna look into that

1 Like

But its about making them fade out, not just checking how far something or someone is

So. You’ll have to check stuff and everything…

First of all you’ll need to do a function to check distance every single new frame. You can use RunService to connect a function to every new frame.

local RS = game:Get service("RunService")
RS.RenderStepped:Connect(function()
-- code
end)

I believe it should be something like this.

You’ll also need to have a variable to tell if it’s hidden already or being hidden. Like local visible = false
And then only do the animation if that variable is right, and if it’s close enough, or far enough.

local visible = false
local RunService = game:GetService("RunService")

local distance = "magnitude or whatever you shouldn't have a variable this is just to explain"

RunService.RenderStepped:connect(function()
 if distance >= 100 and visible == true then
   visible = false
   -- animation to hide
 elseif distance <= 100 and visible == false then
      visible = true
      --animation to appear
end

To do the animations, either with transparency or whatever, you need Tween Service. Here’s some tween service example.

local ts = game:GetService("TweenService")

local function Hide()
  local tInfo = TweenInfo.new(
  .5, 
  Enum.EasingStyle.Quint,
  Enum.EasingDirection.Out,
  0, false, 0)
  local goal = {}
  goal.Transparency = 1 
  local tween = ts:Create(billboardgui frame or whatever, tInfo, 
  goal)
  tween:Play()
end

I’m on my phone rn I can’t really explain well. Or write well.

1 Like

wait so do i have to edit the script or did you just make the entire script

… I am explaining, no one will make an entire script for you. You need to learn the basics about what you need to use to do something like this.

1 Like

ok i was just asking thanks for the help btw