Independent Technical Resource & Anti-Phishing ShieldVerified Safe
RobloxDownloads.com is an independent diagnostic database. We do NOT host executable binaries (.exe, .dmg, .apk). All download action links redirect directly to verified first-party official sources (Roblox Corporation, Microsoft Store, Apple App Store, Google Play).
Type mismatch (Type A vs Type B): Luau Strict Mode Typing Resolution
Luau type mismatches happen when a variable declared with a specific type is assigned an incompatible value, or when passing an optional nil type (T?) into an API that requires a concrete value. Fix it using type guards (if v ~= nil), type narrowing, or the type assertion operator (::).
LUAU_TYPE_MISMATCH_WARN is a Luau VM and Roblox Studio diagnostic event triggered by "W000: Type mismatch: string cannot be converted into number". Luau type mismatches happen when a variable declared with a specific type is assigned an incompatible value, or when passing an optional nil type (T?) into an API that requires a concrete value. Fix it using type guards (if v ~= nil), type narrowing, or the type assertion operator (::).
| Telemetry Metric | Verified Value |
|---|---|
| Error Signature | W000: Type mismatch: string cannot be converted into number |
| Fault Classification | TYPE_MISMATCH (Luau Typechecker) |
| Affected Subsystems | Luau Type Checker, Script Analysis Window, Autocomplete Engine |
| Engine Verification | Studio 0.650+ / Luau 2026 Engine |
| Quick Remediation | Uses if guards to narrow optional types from T? down to concrete T, satisfying the compiler. |
W000: Type mismatch: string cannot be converted into numberThis exact red trace is logged when the Luau VM or engine runtime encounters a thread halt, unhandled nil reference, or cloud quota block.
Deep-Dive Architectural Root Cause
Roblox Luau introduced a powerful gradual type system. When a script runs with --!strict mode, the type inferrer evaluates all assignments. If a function declares arg: number but receives a string or nil from a remote event, the Luau Script Analysis engine flags it immediately to prevent runtime exceptions in production.
💻 Code Implementation Comparison
Inspect the flawed snippet causing the runtime fault vs. the hardened, production-grade Luau solution.
-- ❌ BROKEN: Passing optional instance into function expecting concrete instance
--!strict
local function applySpeed(humanoid: Humanoid, speed: number)
humanoid.WalkSpeed = speed
end
local character = game.Players.LocalPlayer.Character
-- WARNING: Character can be nil! Passing Model? where Model is expected
local hum = character:FindFirstChild("Humanoid") -- hum is typed as Instance?
applySpeed(hum, 16) -- ERROR: Type mismatch Instance? cannot be converted into HumanoidHalts thread execution, creates memory leaks, or trips engine watchdogs when unexpected nil states occur.
-- ✅ PRODUCTION FIX: Idiomatic Type Guards and Casting
--!strict
local function applySpeed(humanoid: Humanoid, speed: number)
humanoid.WalkSpeed = speed
end
local player = game.Players.LocalPlayer
local character = player.Character
-- Safe Type Narrowing Guard
if character then
local humInstance = character:FindFirstChildOfClass("Humanoid")
if humInstance then
-- humInstance is now narrowed safely to Humanoid by Luau type checker
applySpeed(humInstance, 16)
end
endZero unhandled yields, guarded type narrowing, safe fallback paths, and production reliability.
🛠️ Engineering Resolution Steps
- 1Uses if guards to narrow optional types from T? down to concrete T, satisfying the compiler.
- 2Prefers FindFirstChildOfClass("Humanoid") which returns a typed Humanoid? instead of generic FindFirstChild() which returns generic Instance?.
- 3Eliminates the need for unvalidated type casting by structurally validating state before execution.
⚙️ Roblox Studio Configuration Checklist
❓ Frequently Asked Developer Questions
Does a Luau type mismatch stop my game from compiling?
No. Luau type warnings (W000) do not halt script execution at runtime by default, but they usually indicate subtle logic bugs that will cause runtime crashes under edge conditions.
Related Roblox Studio & Luau Diagnostics
Explore other compiler warnings, runtime exceptions, and developer telemetry tools.