In short
Instance.new("ClassName") makes a new object of that class. The text in quotes in the message is what you passed, and Roblox has no class you can create with that exact name. Check the spelling and capitals against the class list (IntValue, not Intvalue), use GetService for services, and set the object's Name on the next line instead of passing it to Instance.new.
What the message means
ServerScriptService.Leaderstats:5: Unable to create an Instance of type "Intvalue"
Other forms of the same message:
Unable to create an Instance of type "Players"Unable to create an Instance of type "Leaderstats"
Class names are case-sensitive and have no spaces: IntValue, RemoteEvent, ScreenGui, Part. The Script Editor offers them as you type inside Instance.new("; pick from that list.
Some classes exist but cannot be created by scripts, such as services and a few engine-only classes. Their Creator Docs page says Not Creatable.
Causes and fixes
Three things cause this error in practice. Each one below has the smallest code that triggers it, then the fix.
- The class name is misspelt
- The Name was passed instead of the class
- The class is a service or cannot be created
The class name is misspelt
One wrong capital is enough: Intvalue, Remoteevent, Screengui.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
-- Unable to create an Instance of type "Intvalue"
local coins = Instance.new("Intvalue")
coins.Parent = leaderstats
leaderstats.Parent = player
end)
Use the exact class name. In strict mode the Script Editor also underlines a class name it does not know.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player: Player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Parent = leaderstats
leaderstats.Parent = player
end)
The Name was passed instead of the class
Instance.new takes the type of object, not what you want to call it. Instance.new("leaderstats") asks for a class called leaderstats, which does not exist. (The second argument of Instance.new is the parent, not the name.)
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
-- Unable to create an Instance of type "leaderstats"
local leaderstats = Instance.new("leaderstats")
leaderstats.Parent = player
end)
Create the class (a Folder here), then set Name.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player: Player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
end)
The class is a service or cannot be created
Services such as Players, ReplicatedStorage and TweenService already exist, one of each per game. You get them, you do not make them.
-- Unable to create an Instance of type "TweenService"
local TweenService = Instance.new("TweenService")
print(TweenService)
Use game:GetService("Name") for any service.
local TweenService = game:GetService("TweenService")
print(TweenService.Name)
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.
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
- Open Output (Window menu, or the Script tab), clear it with Ctrl+K (⌘K on Mac), and press Play.
- Find the first red line. It starts with the script's place in the Explorer and the line number, such as
ServerScriptService.Shop:12:. - Click the red line. Studio opens that script with the cursor on the failing line.
- Read the lines between
Stack BeginandStack Endunder it: they list the calls that led there, newest first, so you can see which function called the broken one. - 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
Where can I see every class name?
In the Creator Docs engine reference (Classes). Each page shows the exact name and whether it is creatable. The Script Editor also suggests names as you type inside Instance.new(".
Why does Instance.new("leaderstats") not work?
leaderstats is a name, not a class. Create a Folder and set its Name: local f = Instance.new("Folder"); f.Name = "leaderstats".
Should I use the second argument of Instance.new?
It sets the parent right away. Roblox recommends setting properties first and Parent last instead, so the object is not sent to clients half set up.
Can RoCode fix it?
Yes. Paste the Output line into RoCode. It fixes the class name, or the GetService call, in the script in your open place.
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 against the message strings in Roblox Studio itself (macOS build of 13 October 2026) on 23 October 2026. A type check catches misspelt APIs and wrong types, not game logic, so playtest in Studio before you publish.