Unable to cast value to Objectin Roblox Luau: what it means and how to fix it
What it means
A Roblox function needed an Instance (a part, a player, a GUI object) and received something else, usually a string or a number.
The smallest script that triggers it
local TweenService = game:GetService("TweenService")
local part = workspace.Door
local info = TweenInfo.new(1)
local tween = TweenService:Create(part.Name, info, { Transparency = 1 })
The fix
local TweenService = game:GetService("TweenService")
local part = workspace.Door
local info = TweenInfo.new(1)
local tween = TweenService:Create(part, info, { Transparency = 1 })
TweenService:Create needs the object to animate. part.Name is only its name, which is a string.
Common causes
- A name (string) was passed where the object itself was needed.
- FireClient was called without the player as its first argument.
- Arguments are in the wrong order, so a number or table lands in the slot for an Instance.
Practice this until it sticks
A Deep Dive on Instances and function arguments: 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.