Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to set the MaxDistance for a BillboardGui?

Asked by
gitrog 326 Moderation Voter
6 years ago

So, I'm playing with the MaxDistance for a BillboardGui, and no matter how low I set it, you can see it from across the map.

I'm trying to make Custom Nametags, so its a bit of a pain if you can see them from across the map.

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

I'm not entirely sure that this is the problem, but I believe it may be because I assume your BillboardGui is parented to something in Workspace.

Since I have not worked with this property before, I am also assuming that MaxDistance only works locally, so please do not think that this answer is definitely right.


To explain what I said above..

The reason I believe MaxDistance does not work is because it does not have access to a player - it is simply there, but with references to nothing. But when it is inside a player, it has a something to reference (a player, and therefore a character, and then a head), which it can use to compare distances and then toggle visibility based on that.

TL;DR; the BillboardGui needs access to a point for it to be able to compare distances and make use of the MaxDistance property. It does not have that access when it is somewhere global (like Workspace) that does not have any specific thing to reference.

The solution is to parent it to the player's PlayerGui;

  1. So it can be seen by the player, and
  2. So it has something to reference.

Assuming this is a normal script in Workspace/ServerScriptService with the BillboardGui inside it:

local Gui = script:WaitForChild("BillboardGui")

game.Players.PlayerAdded:connect(function(Player)
    Player.CharacterAdded:connect(function() -- PlayerGui resets on character spawn by default
        Gui:Clone().Parent = Player.PlayerGui
    end)
end)

Hope I helped!

~TDP

Ad

Answer this question