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

How do I check if a part is missing?

Asked by 9 years ago

Trying to make a GUI detect if a certain brick is missing but I have no idea on how do I make a script check if a certain brick is not there.

Example:

if 
-- command that checks if it is not there with a certain name
then script.Parent.Frame.Visible = false

New to vehicle /gun scripting.

3 answers

Log in to vote
0
Answered by 9 years ago

Use the FindFirstChildmethod to return the object if it exists.

if not workspace.Model:FindFirstChild("PartName") then
script.Parent.Frame.Visible = false
end
0
Thanks DigitalVeer! VeteranHawk 5 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Make a variable using FindFirstChild.

For example:

Part = Part'sParent:FindFirstChild("PartName")

Then, do an if/then statement, to see if it exists:

if Part == nil then
script.Parent.Frame.Visible = false

Add them all together, and you get this:

Part = Part'sParent:FindFirstChild("PartNameHere")
if Part == nil then
script.Parent.Frame.Visible = false

NOTE: Replace (Part'sParent) with the location of the part's parent, and replace "PartNameHere with the name of the part you want to check that exists or not

Please accept my answer if this helped!

0
The script works but the problem is that it doesnt turn visible/invisible while im still on the seat and only works when I re-sit. VeteranHawk 5 — 9y
Log in to vote
0
Answered by 3 years ago

You need to write something like this:

local PlayerGui = game.Players.LocalPlayer:WaitForChild('PlayerGui')


local Thing = game.Workspace:FindFirstChild('[ Part Name ]')


if Thing == nil then


    PlayerGui.[ Gui ].Frame.Visible = false


end

Just like that.

0
OH, IT WAS 6 YEARS AGO... TinkyWinkyDev 6 — 3y

Answer this question