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

How can I use FindfirstChild?

Asked by 5 years ago

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)
0
You should check the wiki before posting here. There is an in-depth explanation here: http://robloxdev.com/api-reference/function/Instance/FindFirstChild Crazycat4360 115 — 5y

1 answer

Log in to vote
0
Answered by
chomboghai 2044 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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! :)

0
Thanks! for now the slot is showing the equipped slot. cherrythetree 130 — 5y
Ad

Answer this question