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

Destroy BillboardGui when sitting, place it back when leaving seat?

Asked by 4 years ago

The title says it all. How do I Destroy a BillboardGui Inside a part when sitting? Workspace V Seats (folder) V Seat V GUI (BillboardGUI)

Is there a way to find all the GUIs from the seats folder and destroy them when sitting? Also, place them back after leaving a seat Notes: * I want to have only the player SITTING having his BillboardGUI removed LocalScript in StarterGui:

01-- // Services \\ --
02local UserInputService = game:GetService("UserInputService")
03local Players = game:GetService("Players")
04 
05-- // Variables \\ --
06local Player = Players.LocalPlayer
07local Character = Player.Character or Player.CharacterAdded:Wait() -- // If character isn't loaded wait till its added
08local Humanoid = Character:WaitForChild("Humanoid")
09 
10local Seats = workspace.Seats -- // Seats folder where all the seats
11local RANGE = 6 -- // How close you have to be to a seat in order to press E.
12 
13-- // Functions \\ --
14local function GetClosestSeat()
15    local SeatsInRange = {}
View all 43 lines...

1 answer

Log in to vote
0
Answered by 4 years ago

I'm not quite sure what the script you posted has to do with the question, but here's my approach at it. I'll walk you through what I did.

01--Load external dependencies
02local Players = game:GetService("Players")
03    local player = Players.LocalPlayer
04        local character = player.Character or player.CharacterAdded:Wait()
05            local Humanoid = character:WaitForChild("Humanoid")
06 
07--The first thing we are doing is loading all the BillboardGuis, so let's use a for loop to find them all.
08local guis = {}
09for i,child in pairs(workspace.Seats:GetDescendants()) do
10    if child:IsA("BillboardGui") then
11        --We found a BillboardGui, let's save it, as well as its original parent for later
12        guis[#guis + 1] = {
13            Gui = child,
14            Parent = child.Parent
15        }
View all 28 lines...
0
I think this issue is being approached in the wrong manner. Why delete it instead of setting it to Visible (or Enabled) = false? GeneratedScript 740 — 4y
0
He asked for it to be Destroyed so I made a method more similar to that without actually destroying the GUI. zemljorog 80 — 4y
Ad

Answer this question