Expected identifier when parsing expression, got 'nil'

Viewed 42
local httpService = game :GetService("HttpService")
local laber = script.Parent.SurfaceGui.TextLabel
local   URL = "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=100&page=1&sparkline=false"
local   Data = httpService:GetAsync(URL)

local randomJokes = httpService:JSONDecode(Data)

nil.Text = randomJokes.value
1 Answers

Literals can't be used as "prefix expressions" to prefix .name, [exp] for assignments.

The workaround is to wrap literals in parentheses (for example: ("str"):rep(42)).

In your case, you can syntactically fix your code by wrapping nil in parentheses:

(nil).Text = randomJokes.value

which most likely is nonsense semantically, unless someone did

debug.setmetatable(nil, {__newindex = function(_, key, value) ... end})

What did you intend to achieve?

Related