Func load() don`t work

Godot version 4.2.1

extends Node3D

func _ready():
load_car()

func load_car():
var car_scene = load(Game.car_list[Game.current_car_index])
var car_instance = car_scene.instantiate()
add_child(car_instance)
car_instance.position = $Character_pos.position

func _on_slt_btn_pressed():
if Game.current_car_index < 4:
Game.current_car_index -= 1
prew_car()

func _on_nxt_btn_pressed():
if Game.current_car_index > 0:
Game.current_car_index += 1
next_car()

func next_car():
get_child(Game.current_car_index).queue_free()
Game.current_car_index = (Game.current_car_index + 1) % Game.car_list.size()
load_car()

func prew_car():
get_child(Game.current_car_index).queue_free()
Game.current_car_index = (Game.current_car_index - 1 + Game.car_list.size()) % Game.car_list.size()
load_car()


next buton clicked

Seems like you have an Autoload reference to an script called “Game”. Can you show us what that is like?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.