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

attempt to index a nil value, but trying to see if its nil?

Hey. I know I had a similiar problem. But this is another one. I am trying to get Values from a Folder. I have a little script which should see if this Value exists. But now, I just get the error "Attempt to index a nil value. Line 134"

Script:

for i, user in ipairs(UserCount4) do
	
		NumberD2 = 0
		
	    
	repeat
		NumberD2 = NumberD2 + 1
		FName = "User" .. NumberD2
		wait(0.1)
	--Line 134 
until workspace.AllPlayer:FindFirstChild(FName).Value == not nil

4 comments

1

if nil then print("yes") else print("nah") end

0

What he said.

0

Works fine, thanks.

0

can i answer so i can get rep?

1 answer

✓ Accepted answer
if nil then
print("Nil")
else
print("Not nil")

2 comments

0

Hey, does it work for LocalScripts too? I am getting the error, even tho I have the same script. It counts the varaible as not nil first, but after the repeat it does.

0

i'm not sure. try remotes

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