I am trying to get my script to find a random value within another folder but on like 16 where I use square brackets, it says that I attempted to index nil ([box]) with 'Q'.
local numbersentered = {} script.Parent.BackgroundFrame.QuestionNumber.Changed:Connect(function() local box = math.random(1,20) print(box) table.insert(numbersentered, box) for i,v in pairs(numbersentered)do if box == v then local box = math.random(1,20) print(box) table.insert(numbersentered, box) else local text = game.ServerStorage:FindFirstChild("Questions").Q[box].Value for i = 1, #text do script.Parent.TextLabel.Text = string.sub (text, 1, i) end end end end)
Any help is wonderful!
ANSWER: So according to your error, it doesn't seem to have to do with box
. Your error (translated) means that :FindFirstChild("Questions")
is nil.
Note: I can't help you further until I see your hierarchy and what this
Questions
object is that you are looking for.
The full error is:
05:04:51.791 - Players.GoingToAnnoyYou.PlayerGui.ApplicationUI.QuestionScript:16: attempt to index nil with 'Q' 05:04:51.791 - Stack Begin 05:04:51.791 - Script 'Players.GoingToAnnoyYou.PlayerGui.ApplicationUI.QuestionScript', Line 16 05:04:51.792 - Stack End