Hi, I am trying to make a model where the user has to answer a question about the word they saw appear. The only issue is that this error’s when I try to run it. I’m not sure how I could prevent this line from running until needed. I thought about wrapping it as a string but otherwise I would have to run it with loadstring
but this requires LoadStringEnabled to be toggled on which I don’t want, and that I also don’t wanna keep running math.random
with every function having it’s own question. I wanna wrap all my questions and answers in a table.
local button = script.Parent:WaitForChild("Button").ClickDetector
local text = script.Parent:WaitForChild("Screen").SurfaceGui.TextLabel
local http = game:GetService("HttpService")
local website = "https://random-word-api.herokuapp.com/word"
local playing = false
local userplaying : Player = nil
local difficulty = 1
local word = nil
local score = 0
local uhh = {[2] = "nd", [3] = "rd"}
local questions = { --ISSUE STARTS HERE (Notice the "Answer" variable having a premade string.sub to run when I want to.)
{Question = "What is the first letter in the word?",Answer = string.sub(word,1,1),Diff = 1},
{Question = "What is the last letter in the word?",Answer = string.sub(word,#word,#word),Diff = 1},
{Question = string.format("What is the %s letter in the word?",uhh[math.random(2,#word-1)]),Answer = string.sub(word,1,1),Diff = 1}
} --ISSUE ENDS HERE
local selectedquestion = nil
local chatted = nil
How would I do this?