Attempt to index nil with 'Name' error with Split string function

Why output saying: attempt to index nil with ‘Name’ (8-th line)

	local split = cmd:split(" ")
	print(split[1] .. "///" .. split[2] .. "///" .. split[3])
	if split[1] == "function" then
		if split[2] == "openapp" then
			local appname = split[3] .. ""
			local gui:ScreenGui = script.Parent.Parent.Parent.Parent:FindFirstChild(appname)
			gui.Enabled = true

Is it able to get an instance? What happens when you tell it to print appname?

it’s print a correct string


local gui:ScreenGui = script.Parent.Parent.Parent.Parent:WaitForChild(appname)

See if that works because I’ve had the same situation before.

What happens when you try


Nothing, you’re trying to print out an Instance, not a String.

Oh it’s my error. Turns out it finding not in playergui, its finding in players.
But i see it due to WaitForChild() output (Infinite yield possible on ‘Players:WaitForChild(“TSUI”)’)

1 Like

Aren’t we trying to find an instance though? If Roblox finds what you want it to find, doesn’t it print the name of the instance?