I pasted the following code into a global script and the output says, "attempt to index global 'io' (a nil value)." It worked perfectly on the app on my phone; does io.read not exist on roblox? If so, how would I implement it?
print("Welcome to my first RPG!")
print()
print("Reply with 'start' to begin the quest and with 'end' to terminate your progress.")
print()
h = 10
r = io.read()
if(r == ("start"))
then
print()
print("Welcome to your quest! You can begin by replying with a number to select a choice.")
print()
print("1)Take road.")
print("2)Wander into forest.")
print()
r = io.read()
if(r == ("1"))
then print()
print("You travel the long road.")
elseif(r == ("2"))
then print()
print("You begin your trek into the forest.")
else
print()
print("Say a valid number.")
repeat until r == ("1") or r == ("2")
end
print("You have ran upon a group of goblins!")
print()
print("You have "..h.." health remaining")
print("1) Fist fight them!")
print("2) Flee!")
print()
r = io.read()
if(r == ("1"))
then
Gd = math.random(1,10)
R = h - Gd
print()
if(Gd >= h)
then
print("You took "..Gd.." damage. You have been defeated.")
else
print("You take "..Gd.." damage, but still manage to fight them off with "..R.." health remaining!")
end
elseif(r == ("2"))
then print()
print("You run to the nearest river and you are all out of stamina. You can't run for much longer anytime soon.")
elseif(r == ("end"))
then
print()
else print("You must say something valid. Please restart the script.")
end
if(r == ("end"))
then print()
print("You have ended your quest. Please restart the script to begin again.")
end
end

1 comment
io.read() does NOT exist on ROBLOX. You can use GUI TextBoxes or InputBegan instead of this.