attempt to index number with 'Value'in Roblox Luau: what it means and how to fix it
What it means
You used a dot on a plain number. Numbers have no properties, so asking one for .Value fails.
The same error also shows up as:
- attempt to index number with number
The smallest script that triggers it
local coins = Instance.new("IntValue")
local amount = coins.Value
amount.Value = amount.Value + 1
The fix
local coins = Instance.new("IntValue")
coins.Value = coins.Value + 1
amount held the number that was inside coins, and a number has no .Value. Working on the coins object keeps .Value available to read and to change.
Common causes
- A variable holds .Value (a number) and the code later treats it as the object.
- A loop counter or other number is reused under a name you expected to be an Instance or table.
- A function returns a number where you expected a table.
Practice this until it sticks
A Deep Dive on values, objects and leaderstats: 5-minute lessons, each with a quiz. What you miss comes back in the next module. One Deep Dive a day is free. No card.