In short
Object here means a Roblox Instance: a Player, a Part, a Model. A Roblox function wanted one of those for an argument and you passed something else: a UserId or a name instead of the Player, a CFrame instead of the part, or a table of players instead of one. Click the error, look at the call on that line, and pass the object itself.
What the message means
ServerScriptService.Teleporter:9: Unable to cast value to Object
Other forms of the same message:
Unable to cast value to ObjectsUnable to cast to DictionaryUnable to cast to Array
Engine functions convert what you pass into the type they need ("cast" it). A number, string or table cannot become an Instance, so the call fails. Objects (plural) means it wanted a list of Instances.
The message does not say which argument. Check each one on the line against the function's page in the Creator Docs, which lists the type of every parameter.
Causes and fixes
Three things cause this error in practice. Each one below has the smallest code that triggers it, then the fix.
- A UserId or name was passed where a Player is needed
- TweenService got a value instead of the part
- A list was passed where one object is needed
A UserId or name was passed where a Player is needed
RemoteEvent:FireClient, MarketplaceService:PromptGamePassPurchase, TeleportService:TeleportAsync and many others take the Player object. A UserId is a number and a name is a string.
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local GAME_PASS_ID = 123456
Players.PlayerAdded:Connect(function(player)
-- a number where the Player goes: Unable to cast value to Object
MarketplaceService:PromptGamePassPurchase(player.UserId, GAME_PASS_ID)
end)
Pass the Player. If you only have a UserId, get the Player with Players:GetPlayerByUserId and check that they are still in the server.
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local GAME_PASS_ID = 123456
local function promptPass(userId: number)
local player = Players:GetPlayerByUserId(userId)
if player then
MarketplaceService:PromptGamePassPurchase(player, GAME_PASS_ID)
end
end
Players.PlayerAdded:Connect(function(player: Player)
promptPass(player.UserId)
end)
Replace 123456 with your game pass ID. The game pass guide covers the purchase check.
TweenService got a value instead of the part
TweenService:Create(instance, info, goals) takes the object to animate first. Passing part.CFrame or part.Position there gives this error.
local TweenService = game:GetService("TweenService")
local door = workspace:WaitForChild("Door") :: BasePart
local info = TweenInfo.new(1)
-- a CFrame where the part goes: Unable to cast value to Object
local tween = TweenService:Create(door.CFrame, info, { CFrame = door.CFrame + Vector3.new(0, 8, 0) })
tween:Play()
Pass the part, and put the property you animate in the goal table.
local TweenService = game:GetService("TweenService")
local door = workspace:WaitForChild("Door") :: BasePart
local info = TweenInfo.new(1)
local tween = TweenService:Create(door, info, { CFrame = door.CFrame + Vector3.new(0, 8, 0) })
tween:Play()
A list was passed where one object is needed
FireClient(player, ...) sends to one player. Passing Players:GetPlayers(), a team list or your own table of players fails, because a table is not an Instance.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local roundStarted = ReplicatedStorage:WaitForChild("RoundStarted")
-- a table of players: Unable to cast value to Object
roundStarted:FireClient(Players:GetPlayers(), "Arena")
Use FireAllClients for everyone, or loop and call FireClient once per player.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local roundStarted = ReplicatedStorage:WaitForChild("RoundStarted") :: RemoteEvent
-- everyone:
roundStarted:FireAllClients("Arena")
-- or only some players:
for _, player in Players:GetPlayers() do
if player.Team then
roundStarted:FireClient(player, "Arena")
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.
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
What does Object mean in this error?
A Roblox Instance: anything you can see in the Explorer, such as a Player, a Part or a Model. Numbers, strings, tables, CFrames and Vector3s are values, not Objects.
How do I get a Player from a UserId?
Use Players:GetPlayerByUserId(userId). It returns nil if that player is not in the server, so check it before you use it.
What about Unable to cast to Dictionary or Array?
Same idea for tables: the function wanted a table with keys (a dictionary) or a list (an array) and got something else, often nil or a single value. Check the parameter type in the Creator Docs.
Can RoCode fix it?
Yes. Paste the Output line into RoCode. It looks at the call in the script in your open place, finds which argument is the wrong type and passes the right object.
Sources and further reading
- Roblox Creator Docs: MarketplaceService:PromptGamePassPurchase
- Roblox Creator Docs: TweenService:Create
- Roblox Creator Docs: RemoteEvent
- Roblox DevForum: Unable to cast value to Object (TeleportAsync with a UserId)
- Roblox DevForum: Unable to cast value to Object (a tween aimed at a CFrame)
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; the causes are the ones DevForum threads on this error resolved. A type check catches misspelt APIs and wrong types, not game logic, so playtest in Studio before you publish.