Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Output error " = expected near 'ME' " on one line but not a basically identical other line?

Asked by 5 years ago
Edited 5 years ago
math.randomseed(tick())
local number = (math.random(2))
if number == 1 then
    script.Parent.Value = Voltison Augusta ME 
elseif number == 2 then
    script.Parent.Value = Voltison Belfast ME
end

The output error says that error is occurring on line 4, but line 6 is identical in every way except the city name is different, and no errors there. If I put two equals signs on line 4, the error goes away, but it's replaced with what I knew would happen, " = expected near ==' I've tried putting it in random places and nothing happens. I've tried making it "AugustaME" but then the error transfers to line 5. Where is the = supposed to go?

0
By the way this is not where I live, I'm just building a game that involves these two cities. sesamert16 31 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

You're assigning your value wrong. Instead of Voltison Augusta ME, do "Voltison Augusta ME" in quotation marks to specify it's a string value.

Ad
Log in to vote
0
Answered by
Syclya 224 Moderation Voter
5 years ago

Correct syntax:

local number = math.random(1, 2)

You can also look up Random.new().

Answer this question