StreamTexture in Godot 4: Could not find type "StreamTexture"
StreamTexture is called CompressedTexture2D in Godot 4. A Godot 3 script that types a variable as StreamTexture fails to parse with Could not find type "StreamTexture" in the current scope; type it as CompressedTexture2D, or as Texture2D if any 2D texture will do.
AppImage, x86_64. Ubuntu 22.04, Debian 12, Fedora 39 or newer.
Intel or AMD Chromebook, with Linux turned on.
What Godot is checking
When GDScript loads a script it resolves every type annotation. StreamTexture is not a class in Godot 4, so the analyzer stops with Could not find type and none of the script runs.
Godot 4 renamed the texture an imported image loads as. Its 3-to-4 converter carries StreamTexture and StreamTexture2D to CompressedTexture2D, StreamTexture2DArray to CompressedTexture2DArray, and StreamTextureLayered to CompressedTextureLayered.
The class reference describes CompressedTexture2D as a texture loaded from a .ctex file, a format internal to Godot that the import system creates from other image formats. It inherits Texture2D, which the fix printed.
More on this: StreamCubemapArray in Godot 4: Identifier not declared in the current scope
Reproduce it
A Godot 3 script that types a texture as StreamTexture, in a Godot 4 project. The scene is one Node with this script.
extends Node
var icon: StreamTexture
func _ready():
print(icon)
What Godot 4.7.2 prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
SCRIPT ERROR: Parse Error: Could not find type "StreamTexture" in the current scope.
at: GDScript::reload (res://answers/streamtexture-in-godot-4/repro.gd:3)
ERROR: Failed to load script "res://answers/streamtexture-in-godot-4/repro.gd" with error "Parse error".
at: load (modules/gdscript/gdscript_resource_format.cpp:46)Fix it
Type it as CompressedTexture2D. A texture loaded from an imported image is one, and it is a Texture2D, so a variable typed Texture2D also takes it.
extends Node
var icon: CompressedTexture2D = CompressedTexture2D.new()
func _ready() -> void:
print(icon.get_class(), " is Texture2D: ", icon is Texture2D)
print("parent class: ", ClassDB.get_parent_class("CompressedTexture2D"))
What the fixed script prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
CompressedTexture2D is Texture2D: true
parent class: Texture2DRun this fix with your agent
Flockbay is the Godot editor with an AI agent built in. Paste this into Flockbay's chat, or into Claude Code or Codex connected to Flockbay over MCP: the agent finds the cause in your project, applies the fix, runs the game headless and reads Godot's output to check it.
More on this: Physics2DDirectBodyState in Godot 4: it is PhysicsDirectBodyState2D now
My Godot project was written for Godot 3 and Godot 4 stops on this: "Parse Error: Could not find type "StreamTexture" in the current scope.". Port every use to Godot 4. StreamTexture is called CompressedTexture2D in Godot 4. A Godot 3 script that types a variable as StreamTexture fails to parse with Could not find type "StreamTexture" in the current scope; type it as CompressedTexture2D, or as Texture2D if any 2D texture will do. Then run the game headless and check Godot's output for errors.Verified on Godot 4.7.2
Both scripts on this page were run headless on Godot 4.7.2 (4.7.2.stable.mono.official.ed1daf0bf) on 6 October 2026, and the output above is what Godot printed, unedited.
Where the check lives in Godot's source: gdscript_analyzer.cpp line 904, the message, renames_map_3_to_4.cpp lines 1607 to 1610, StreamTexture to CompressedTexture2D, CompressedTexture2D class reference.
Questions
- What about StreamTexture2D, StreamTextureLayered and StreamTexture2DArray?
- They took the same rename: StreamTexture2D is CompressedTexture2D, StreamTexture2DArray is CompressedTexture2DArray, and StreamTextureLayered is CompressedTextureLayered.
- Should I type the variable as CompressedTexture2D or Texture2D?
- CompressedTexture2D inherits Texture2D. Type it Texture2D when the variable may also hold a texture made in code, such as an ImageTexture; CompressedTexture2D only fits a texture loaded from an imported file.
Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.
Download Flockbay free