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

Why when the script locates the model its considered a nil value?

So my plane i'm working on I'm adding a bomb feature but for some reason on line 187 (I took a snippet of the code so you don't have to go through all of that) its detected as a nil value when all its doing is, is trying to find the part named BombLoc

code

local bombspawn = script.Parent.Parent.Parent.Parent:FindFirstChild("Design"):FindFirstChild("BombLoc") -- error
function bomb()
if bombreload == true then
	print'reloading bombs'
	else
local bb = game.ServerStorage.Bomb:Clone()
bb.Parent = game.Workspace
bb.Position = CFrame.new(bombspawn.Position)
bombreload = true
wait(15)
bombreload = false
	end
end
function KeyDown(k)
	if (k == "w" or k:byte() == 17) then
		throttle.up = (true and not dead)
	elseif (k == "s" or k:byte() == 18) then
		throttle.dn = (true and not dead)
	elseif (k == "g" and not properties.autoLandingGear and not dead) then
		ToggleLandingGear()
	elseif (k == "b" and properties.pushback and not dead) then
		TogglePushback()
		elseif (k == "f" and bombreload == false) then
		bomb()
	end
end

1 answer

Use the YieldFunction WaitForChild(), rather than FindFirstChild()

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