FindFirstChild appears to be having a stroke

Hello. I have an airplane game, and I had the entire system in a local script. Unfortunately, it was only client side, so only Player 1 could see that they shoot down Player 2.
I copy pasted the entire code into a SCRIPT not a LOCAL SCRIPT. However, it is being difficult. Here is a screenshot.


I have no errors, but I get an outpouring of “Steel Inquisitor is searching for the script.”
Please help!!!

I would remove the repeat function, and use WaitForChild instead.

2 Likes

Thank you! I will try that. 3030303030

No luck. I checked the dev console and there is nothing but it is just plain refusing to work.

What is happening it is failed to find the child, then it started the loop. It never tried again.

1 Like

Oh, okay. So what I should do is put findfirstchild in the loop?

1 Like

Still not working. I still receive a barrage of “Steel Inquisitor is searching for the script.”

Can you paste the script here?

1 Like

Okay.
Version #1
(Repeat Loop.)

local plane = script.Parent.Parent.Parent.Parent.Parent
local scripty = plane:FindFirstChild("Kar")
repeat
	local scripty = plane:FindFirstChild("Kar")
	wait()
	print("Steel Inquisitor is searching for the script.")
	
until scripty
scripty.Disabled = false

Filled with Steel Inquisitor
Version #2
WaitForChild

local plane = script.Parent.Parent.Parent.Parent.Parent
local scripty = plane:WaitForChild("Kar")
scripty.Disabled = false

There is an infinite yield on this.

Version #2 should work fine. If you do want to have the repeat loop with the printing. Then maybe something like this:

local plane = script.Parent.Parent.Parent.Parent.Parent
if not plane:FindFirstChild("Kar") then
    repeat
	    wait()
	     print("Steel Inquisitor is searching for the script.")
    until plane:FindFirstChild("Kar")
end
scripty.Disabled = false

“Kar” appears to be a script, not local script. A local script won’t be able to find it. A regular script should. Have you checked, while the game is playing, that Kar is still visible on the server?

1 Like

Remove all the parents and make it just one.

local plane = script.Parent
local scripty = plane:WaitForChild("Kar")
scripty.Disabled = false
1 Like

This is part of the issue as well, I assume.

1 Like

I changed every local script to a regular script so it could find oher scripts. However I am a bit confused. Can LocalScripts only find other LocalScripts?
And I have an error. Infinite Yield possible on "Wait for child “Kar”

Current Script:

local plane = script.Parent
local scripty = plane:WaitForChild("Kar")
scripty.Disabled = false

One more thing. Printing "Steel Inquisitor is searching for the script." so many times every wait() is bad. (Also use task.wait()) Maybe you should make a function and get the function to just wait before printing. Maybe using a debounce.

local Debounce = false
function PrintSearching()
      if Debounce == false then
         Debounce = true
         print("Steel Inquisitor is searching for the script.")
         ask.wait(1)
         Debounce = false
    end
end

then use a coroutine and wrap the function so it doesn’t stop the repeat.

repeat
    task.wait()
    coroutine.wrap(PrintSearching)()
end
1 Like

Wait what?!?!?! Sorry Im new. Do I put the repeat after the function? Are you sure to put an end after repeat? I though it was until.

Sigh…
everyone left me lol. 303030

local plane = script.Parent

local scripty = plane:WaitForChild("Kar")

scripty.Disabled = false

I used this script and it worked just fine, both of the scripts were normal scripts, not local.

1 Like

Thank you! It worked!!!