Attempted to call a nil value

Hey, I’m making a script that checks for external guis added by a backdoor.

But I’ve encountered a problem:

for i, v in pairs(game.Players:GetChildren()) do
	for i, v in pairs(v.PlayerGui:GetChildren()) do
		for i, v in pairs(v.Name:GetChildren()) do
			if v.Name == "CodeBox" or v.Name == "Execute" or v.Name == "SS" then
				script.Parent.Parent.Text = "found external gui"
			else
				print(v.Name.. " no signs of external guis.")
			end
		end
	end
end

The error code I’m getting:

 Players.V33S.PlayerGui.ScreenGui.Frame.Frame.TextLabel.for :3: attempt to call a nil value  -  Server - for :3
 Stack Begin  -  Studio
  Script 'Players.V33S.PlayerGui.ScreenGui.Frame.Frame.TextLabel.for ', Line 3  -  Studio - for :3
  Stack End

No clue what is causing this error though?

Thanks for any help!

Name is a property, so it doesn’t get a child of the object.

1 Like

Wouldn’t it get the name then find that in player gui and get the children?

Property names have priority over actual names of children, rename whatever is called Name to something else.

Also, I recommend you give your in pairs stuff descriptive names instead of i and v, since you’re technically overwriting them 3 times

1 Like

Could you explain what you mean by giving pairs descriptive names?
I didn’t know you could do that nor do I know how.

You can simply use FindFirstChild if you want the script to know that you are trying to get a child.

Simply just renaming these vs to something that describes their contents.

Such as

for _, player in pairs(game.Players:GetChildren()) do
	for _, gui in pairs(player.PlayerGui:GetChildren()) do
		for _, object in pairs(gui.Name:GetChildren()) do

Also I can’t rename it since it’s a gui the player is not inserting it, and it is only inserted when the game is running, I think that’s how backdoor’s load their guis atleast.

Then do as @ProBaturay and use FindFirstChild to get the child called Name

v:FindFirstChild("Name")
1 Like

How would you use FindFirstChild in that script?

I’ll give it a go and tell you if it works

Something like this, also including what I had mentioned

for _, player in pairs(game.Players:GetChildren()) do
	for _, gui in pairs(player.PlayerGui:GetChildren()) do
		for _, object in pairs(gui:FindFirstChild("Name"):GetChildren()) do
			if object.Name == "CodeBox" or object.Name == "Execute" or object.Name == "SS" then
				script.Parent.Parent.Text = "found external gui"
			else
				print(object.Name.. " no signs of external guis.")
			end
		end
	end
end

Keep in mind you’ll get an error if there’s nothing called Name in the gui

Although I think you’re meaning to check the gui and not the contents of the gui

@FrazedGreatness2 also i’m too lazy lol

2 Likes

Do game.Players:GetPlayers() :grinning_face_with_smiling_eyes:

I think:

for _, Player in pairs(game.Players:GetPlayers()) do
	for _, Gui in pairs(Player:WaitForChild("PlayerGui"):GetChildren()) do
		for _, Object in pairs(Gui:GetDescendants()) do
			if Object.Name == "CodeBox" or Object.Name == "Execute" or Object.Name == "SS" then
				script.Parent.Parent.Text = "Found external gui at player " .. Player.Name .. ", gui object: " .. Object:GetFullName()
				-- I would not print for each object
			end
		end
	end
end

Are you trying to run this whilst playing or not? Backdoors can hide on lots of different places too. They just need to send an event to the server. I know much backdoor creators and exploiters are smart to make their gui names different and obscured. This wouldn’t be strong against them.

Edit:
Also, clients can put something on their client, then that will not replicate to the server.

1 Like

Yes I am trying to run it whilst playing, and I know it isn’t that secure so I will also add a few other things to check since some serversides get leaked you can find patterns in object names and detect them.