Roblox Studio error

attempt to index number with 'X'

What attempt to index number with 'X' means in Roblox Studio, the three things that cause it with the code that triggers each, and the fix for each one.

Updated 23 October 20263 min readErrorLuau

In short

A dot only works on objects and tables. This error says the value before the dot was a number (or a boolean, in the boolean version), so it has no .Value, .Name or any other field. Most often you already read .Value once and then tried to read it again, or the two loop variables of ipairs are the wrong way round.

On this page
  1. What it means
  2. Causes and fixes
  3. Fix it with RoCode
  4. Find the line
  5. Questions
  6. Sources

What the message means

Output (example)
ServerScriptService.CoinPad:7: attempt to index number with 'Value'

Other forms of the same message:

  • attempt to index boolean with 'Parent'
  • attempt to index number with 'Transparency'

Numbers and booleans are plain values. They have no children and no properties, so 5.Value or true.Parent has nothing to read. Luau names the type it found (number, boolean) and the key you asked for.

Strings behave differently: reading an unknown name from a string gives nil without an error, so a mistake with a string shows up one step later as attempt to index nil or attempt to call a nil value.

Causes and fixes

Three things cause this error in practice. Each one below has the smallest code that triggers it, then the fix.

You read .Value, then used it like the object

coins.Value is a number. If you save it in a variable and later write coins.Value again on that number, you get attempt to index number with 'Value'. Saving the number also means changing the variable never changes the real stat.

Breaks Script in ServerScriptService named CoinPad
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	local leaderstats = player:WaitForChild("leaderstats")
	local coins = leaderstats:WaitForChild("Coins").Value -- a number
	-- attempt to index number with 'Value'
	coins.Value += 10
end)

Keep the object (the IntValue) in the variable, and read or change .Value on it when you need it.

Fixed Script in ServerScriptService named CoinPad
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player: Player)
	local leaderstats = player:WaitForChild("leaderstats", 10)
	local coins = leaderstats and leaderstats:WaitForChild("Coins", 10)
	if coins and coins:IsA("IntValue") then
		coins.Value += 10 -- changes the stat itself
	end
end)

The ipairs variables are the wrong way round

ipairs gives the position first and the value second. Writing for part, i in ipairs(list) makes part the number 1, 2, 3, and the first dot on it fails.

Breaks Script in ServerScriptService named Lights
local folder = workspace:WaitForChild("Lights")

for light, i in ipairs(folder:GetChildren()) do
	-- light is the index (a number): attempt to index number with 'Transparency'
	light.Transparency = 0.5
end

Put the index first. Use _ when you do not need it, and check the class before setting a property only some objects have.

Fixed Script in ServerScriptService named Lights
local folder = workspace:WaitForChild("Lights")

for _, light in ipairs(folder:GetChildren()) do
	if light:IsA("BasePart") then
		light.Transparency = 0.5
	end
end

A true or false went where an object should be

Functions like IsA, IsDescendantOf and comparisons return true or false, not the object. Using that result with a dot gives attempt to index boolean with. The same happens with x == y and x style shortcuts written the wrong way round.

Breaks Script in a Part in Workspace named Greeter
local part = script.Parent

part.Touched:Connect(function(hit)
	local isCharacterPart = hit.Parent:FindFirstChild("Humanoid") ~= nil
	-- a boolean: attempt to index boolean with 'Parent'
	print(isCharacterPart.Parent.Name)
end)

Keep the object and the check in separate variables: the object to use, the boolean only in the if.

Fixed Script in a Part in Workspace named Greeter
local part = script.Parent :: BasePart

part.Touched:Connect(function(hit: BasePart)
	local character = hit:FindFirstAncestorOfClass("Model")
	local humanoid = character and character:FindFirstChildOfClass("Humanoid")
	if character and humanoid then
		print(character.Name)
	end
end)

Fix it in your place

Paste the error, RoCode fixes it in your place

Copy the line from Output and paste it here. RoCode opens the script it names in the place you have open in Studio, works out which of the causes above it is, and edits the code there instead of handing you a snippet to paste.

For example: ServerScriptService.CoinPad:7: attempt to index number with 'Value'

RoCode is an AI agent for Roblox Studio: it reads the scripts in the place you have open, finds the line and edits it there, and every change is an undo point. It runs on Windows or macOS with a desktop browser. Free to start, with free credits every day.

How to find the line that causes it

  1. Open Output (Window menu, or the Script tab), clear it with Ctrl+K (⌘K on Mac), and press Play.
  2. Find the first red line. It starts with the script's place in the Explorer and the line number, such as ServerScriptService.Shop:12:.
  3. Click the red line. Studio opens that script with the cursor on the failing line.
  4. Read the lines between Stack Begin and Stack End under it: they list the calls that led there, newest first, so you can see which function called the broken one.
  5. Still not sure which value is wrong? Add print(typeof(x), x) just above the line, or set a breakpoint on it and read the values in the Watch window.

Questions

What does attempt to index number with 'Value' mean?

You wrote .Value on something that is already a number, almost always because you saved stat.Value in a variable earlier. Save the IntValue or NumberValue object instead and use .Value on it.

Why does changing my saved number not change the leaderboard?

A number is copied when you put it in a variable. Changing the copy does nothing to the IntValue. Keep a reference to the object and set object.Value.

What about attempt to index boolean with 'X'?

Same idea with true or false: a check such as IsA or ~= returned a boolean, and the code then used it like an object. Use the object you checked, not the result of the check.

Can RoCode fix it?

Yes. Paste the Output line into RoCode. It reads the script in your open place and changes the variable to hold the object, or fixes the loop, where the error happens.

Sources and further reading

How the code was checked: every block marked Fixed passes Luau's strict type checker against Roblox's API definitions (luau-lsp, 23 October 2026), and every block marked Breaks compiles and fails only when it runs. The message wording was checked by running the broken code with the Luau command line tool and against the message strings in Roblox Studio itself on 23 October 2026. A type check catches misspelt APIs and wrong types, not game logic, so playtest in Studio before you publish.

Stop hunting errors line by line.

RoCode reads the scripts in your open place, fixes the error where it happens and tells you what it changed. Free every day, no card required.