Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I use FindfirstChild?

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)

1 comment

0

You should check the wiki before posting here. There is an in-depth explanation here: http://robloxdev.com/api-reference/function/Instance/FindFirstChild

1 answer

✓ Accepted answer

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

1 comment

0

Thanks! for now the slot is showing the equipped slot.

This discussion is preserved as it was. New answers, comments, and votes are closed.