Hi ! This is Godot v 4.7
EDIT 1: Updated this to what’s already tested to avoid duplicated to someone who recently viewed this and rephrasing my words to make it more clear
I tried to added instantiated scene into array, it’s working well and fine when playing for few seconds-minute in. The bug (the title stated) occured, and it’s only occured on one customer in party (The game generated random amount of customers)
Customer and Individual Customer generation
func _on_customer_spawn_cooldown_timeout() -> void:
var customer_generated_amount = 0
var randomize_spawn = rng.randi_range(1,3)
if Global.current_customer_waitinginline < children_inspawn.size() and Global.current_customer_inscene < Maxed_customer_inscene:
match randomize_spawn:
1:
if Global.av_big_table > 0:
customer_generated_amount = rng.randi_range(3,5)
Global.av_big_table -= 1
2:
if Global.av_mid_table > 0:
customer_generated_amount = 2
Global.av_mid_table -= 1
3:
if Global.av_small_table > 0:
customer_generated_amount = 1
Global.av_small_table -= 1
_: print_debug("Nothing is spawned")
var CUS = CUSTOMER.instantiate()
for i in customer_generated_amount:
var INV_CUS = INVID_CUSTOMER.instantiate()
CUS.customer_inparty.append(INV_CUS)
print_debug("Customer in party in spawn:","at",i,"index",CUS.customer_inparty)
print_debug(INV_CUS.get_instance_id())
print_debug(is_instance_valid(INV_CUS))
for i in children_inspawn:
if i.get_child_count() == 0:
i.add_child(CUS)
print_debug("Customer in party in spawning into marker:",CUS.customer_inparty)
print_debug(i.get_instance_id())
print_debug(is_instance_valid(i))
Global.current_customer_waitinginline += 1
Global.current_customer_inscene += customer_generated_amount
break
This code is working fine when debugged, the customer spawned in correct amount and can be seen. But the problem ONLY when it’s added into table itself and it’s only happen to one customer sometimes and it’s fixed itself some table in the same table (Customer queue freed when everyone in the same table have recieved their orders)
On the second print_debug lines of “Customer in party in spawn” the Individual Customer disappred from Customer Array
extends Control
var table_isavaliable: bool = true
var customer_inchairtaken: Array = [] #Use for clearing customer out
var customers_taken: Dictionary = {}
enum TYPES {Small,Mid,Big}
@export var table_type: TYPES
@onready var chair_location = $Chair_avaliable.get_children()
@onready var number_ofchairs = len($Chair_avaliable.get_children())
enum STATES {Freed, Taken}
var index:int = 0
var amount_ofcustomer:int = 0
var amount_ofcustomertaken:int = 0
func _ready() -> void:
checking_orders()
func _process(delta: float) -> void:
#TODO check if all customer has successully taken their orders
if not customers_taken.is_empty():
checking_orders()
#TODO then queue freed customer / removed taken to empty
#print_debug(customers_taken)
if amount_ofcustomertaken == amount_ofcustomer:
for i in customer_inchairtaken:
if is_instance_valid(i):
Global.current_customer_inscene -= 1
print_debug("Customer in party in table cleared",customers_taken)
i.queue_free()
customers_taken = {}
table_isavaliable = true
if amount_ofcustomer >= 3 and amount_ofcustomer <= 6:
Global.av_big_table += 1
elif amount_ofcustomer == 2:
Global.av_mid_table += 1
elif amount_ofcustomer == 1:
Global.av_small_table += 1
func take_chair(customer) -> void:
print_debug("Customer in party in pre-assigned table", customer.customer_inparty)
print_debug(is_instance_valid(customer.customer_inparty))
if is_instance_valid(customer):
if not customer.customer_inparty.is_empty():
for i in customer.customer_inparty:
print_debug("Customer in party in assigned table", customer.customer_inparty)
print_debug(i.get_instance_id())
print_debug(is_instance_valid(i))
if i != null:
var CUS = i
chair_location[index].add_child(CUS)
#print_debug(CUS.global_position)
customer_inchairtaken.append(CUS)
CUS.inside_table = true
customers_taken[CUS] = STATES.Freed
Global.data_tracking["Customer taken"] += 1
index += 1
else:
Global.av_small_table += 1
Global.current_customer_inscene -= 1
index = 0
table_isavaliable = false
amount_ofcustomer = len(customers_taken)
func checking_orders():
amount_ofcustomertaken = 0
for keys in customers_taken:
if is_instance_valid(keys):
var value = customers_taken[keys]
if keys.order_recieved:
customers_taken[keys] = STATES.Taken
match value:
STATES.Taken:
amount_ofcustomertaken += 1
STATES.Freed:
amount_ofcustomertaken -= 1
I tried somewhat making placed customer instantiate and add child and it doesn’t help anything (same bug still occured)
Comparsion between Normal and Bugged
The code in the picture is in older version, but everything still working the same as current version
Any help would be appreciate! as i have finally hit rock bottom with this
PS. if anyone struggled reading my english/grammar please also do let me know as i can rephrased the confusion you have


