Viewport not updating properly

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DV56

Hey there! I’m trying to render a scene as a transparent overlay atop of another scene using a viewport. I have gotten it to properly display my chosen scene, however, I am having difficulties getting it to switch scenes from any other scene besides the first one I had initially loaded.

Here is my code:

func _preview(timeline, state):
print(timeline)

preview.visible = true
var current_time = load("res://Resources/Nodes/Scenes/Levels/"+ Level +"/Timelines/" + timeline as String + ".tscn").instance()
viewport.call_deferred("add_child", current_time)
var rtt = viewport.get_texture()
preview.get_node("Container/Sprite").texture = rtt
if last_preview:	
	last_preview.queue_free()
last_preview = current_time

This function is called whenever the player presses Q or E, and the timeline variable is always a number 1-5 (Which corresponds with the name of the scene it’s loading)

Here’s my node hierarchy!
enter image description here

Here is an example of it in action, but with numbers 2-5 not working
Youtube Link