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. What is wrong????

This is in a script in SSS

local trigger = false

for i, v in pairs(game.Players:GetPlayers()) do
  if v.ValueName.Value == true then
    trigger = true
  end
end

if not trigger then
    TestSubject1()
end

-- { Functions }



function TestSubject1()
    print("Hello.")
end

The part where the error takes place is when it says TestSubject1(

4 comments

0

You sure you spelled it right?

0

and if my answer in your last question fixed your problem please do accept it as an answer.

0

Please show us the error too.

0

Try removing the number from the functions end, I don't know if it would matter or not but you can try. If it doesn't work you can also try moving the function above the call (line 10)

1 answer

✓ Accepted answer

Ah, yes you have to refrence the function BEFORE you use it so it would be like this:

local trigger = false

for i, v in pairs(game.Players:GetPlayers()) do
  if v.ValueName.Value == true then
    trigger = true
  end
end
function TestSubject1()
    print("Hello.")
end
if not trigger then
    TestSubject1()
end

3 comments

2

Thanks! I also accepted the other one.

0

Weird, its not displaying it as answered you sure did lol?

0

mhm

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