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

How do you use FindFirstChild to find an object?

Asked by 5 years ago

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!

0
This works for me when I try in studio. oftenz 367 — 5y
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 RetroGalacticGamer 331 — 5y
0
nevermind what I said heh heh RetroGalacticGamer 331 — 5y
0
It works? there's no problem ihatecars100 502 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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 9423in 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.

Ad

Answer this question