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

How do you use FindFirstChild to find an object?

Here is my script, it isn't working.

function Examp()
	VariableName = 9423
	if game.Workspace:FindFirstChild(VariableName) then
		print("It worked")
	end
	print(VariableName)
end

The point of this script is to find a part Named 9423 but even if that part exists, the game will still think the part does not exist. Please only help if you really know the answer. Thanks!

4 comments

0

This works for me when I try in studio.

0

What the heck you are creating a variable that is equal to a number not the part and then you are using find first child to find the variable WTFFFFFFFFFFFFFFFF

0

nevermind what I said heh heh

0

It works? there's no problem

1 answer

✓ Accepted answer

Ok so it actually does. Make sure your part in workspace is named 9423 and you are calling the function Examp(). Although it will work, I strongly suggest changing the variable to a local variable and putting quotes around 9423 in line 2, like this:

function Examp()
local VariableName = "9423"
	  if game.Workspace:FindFirstChild(VariableName) then
	     print("It worked")
	  end
   print(VariableName)
end
Examp()

If this doesn't solve your problem, then you should probably investigate and check to see if roblox studio is running properly for you by doing tests. If roblox studio is working but it still isn't, then I don't know what to tell you. Oh also there might be another script interfering with your script. If there is, then modfiy that script to allow this to work.

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