I was trying to make an Backpack Gui, So when the player can see the image slot. But how to use FindfirstChild instead of using Parents?
script:
local U = game:GetService("UserInputService") local debounce = true U.InputBegan:Connect(function(key) --Not interested to use InputEnded so. if key.KeyCode == Enum.KeyCode.One then if debounce == true then debounce = false print("On!") script.Parent. -- I don't know how to use FindFirstChild yet. else debounce = true print("Off.") end end end)
FindFirstChild is a method that can be used on any instance.
To use it, you simply put a colon :
after a reference to the instance you want to look through, and then FindFirstChild(name)
, where name is the name of the object you want to look for.
For example, if I wanted to look for an instance named "LookForThisPart" in workspace
, I would do:
local part = workspace:FindFirstChild("LookForThisPart") --[[ print(part.Name) > LookForThisPart ]]--
If the object is found, it will return a reference to that object, otherwise it will return nil
.
Hope this helps! :)