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

Is there a way to make BillBoardGui's go away after a certain distance?

Asked by 9 years ago

Say that you are within 1000 studs of a BillBoardGUI, and no matter how big the text/BillBoardGui is, you can still view it. But if you step outside the 1000 stud radius, you cannot see the BillBoardGui.

Is there a scripting method that accomplishes this or not?

1 answer

Log in to vote
0
Answered by
Xetrax 85
9 years ago

I have written a script like this once, but forgive me because I can't find it to copy in the code, but it worked like this: It created the BBGUI, and set the BBGUI's Adornee property to the object its supposed to be connected to, then it cloned and parented the BBGUI to the localplayer, making it so only they can view it, it looks like so(Did my best recreation, excuse the sloppyness or possible inaccuracy):

local Player = game.Players.localPlayer;
local GuiPart = game.Workspace:FindFirstChild("GuiAdornee");
local MaxRange = 1000;
local BBGUI = Instance.new("BillboardGui", script.Parent);  --[ This makes a BBGUI for every player, since the Player is the game.Players.localPlayer. ]
BBGUI.Adornee = GuiPart;
BBGUI.Size = UDim2.new(1, 0, 1, 0);

while true do
    if Player:DistanceFromChatacter(GuiPart.CFrame.p) > MaxRange then
        BBGUI.Enabled = false
    else
        BBGUI.Enabled = true
    end
    wait()
end

Hope that helps. :) OH, one last thing, this will have to be in a LocalScript in the Player's PlayerGui.

0
Thanks! CoolJohnnyboy 121 — 9y
Ad

Answer this question