I was just pulling my hair out over this typo. In Checkpoint
's constructor, spawnlocation
was misspelled as spawnloacation
.
type Checkpoint = {
spawnlocation: SpawnLocation,
conn: RBXScriptConnection,
level: number,
gui: SurfaceGui,
}
local Players = game:GetService("Players")
local Checkpoint = {}
Checkpoint._index = Checkpoint
function Checkpoint.new(spawnlocation: SpawnLocation): Checkpoint
local level = spawnlocation:FindFirstChild("Level")
assert(level and level:IsA("IntValue"))
local newcheckpoint: Checkpoint = {
spawnloacation = spawnlocation,
--[[
...
--]]
}
--[[
...
--]]
setmetatable(newcheckpoint, Checkpoint)
return newcheckpoint
end
However, this typo doesn’t exist in the type definition at the top of the script. For whatever reason, Luau didn’t complain about this typo, despite me setting the return type of a constructor to Checkpoint
. Instead, I had to find this out the normal way by freaking out and putting print statements everywhere.