Attempt to index nil with "FindFirstChild" error

edit: i used the correct noob tube, not the cloned ones.
hello, this very night i got bored and decided to make a remastered noob tube, but a error stops me from it, i dont know how to fix this


and this is a really short script because im kinda worried someone is gonna steal it

	local chosen
	local random = math.random(1,100) if random == 10 then
		chosen = game.ServerScriptService.Noob:Clone()
	end
	if random == 50 then
		chosen = game.ServerScriptService.BadNoob:Clone()
	end



	local noob = chosen
	noob:FindFirstChild("HumanoidRootPart").CFrame = pos
	noob.Humanoid.HumanoidMain.Disabled = false
	noob.Main.Disabled = false
	debris:AddItem(noob,600)
	Tool.ToolTip = "Spawn a noob, if your lucky enough u might get other noobs!"
	Tool.Enabled = true
end

i dont really know why it doesnt find the humanoid root part.

Well with your random chooser, it will only work if it chooses either 10, or 50. If it is any other number, chosen is left as nil.

fixed the random chooser, still doesnt find the humanoidrootpart, and if i disable the line it doesnt find humanoid

What does the fix that you did look like?


em

it still does the unfunny error :frowning_face:

It’s still the same case. If the random number is neither 10 nor 90, chosen will be nil. (2% chance)

Are you meaning to use >= or <=?

1 Like

Oh you kinda just redid your mistake again lol. This is what it should be structured like (keep in mind im not sure exactly how you want it, so take this as a blueprint)

local chosen
local random = math.random(1,100) 
if random <= 50 then
	chosen = game.ServerScriptService.Noob:Clone()
end
if random > 50 then
	chosen = game.ServerScriptService.BadNoob:Clone()
end

You just have to tell the script to do something with the numbers that aren’t just 10 or 50

1 Like