Godot Version
4.6.2
Question
I am trying to randomize an array when i press a button and then show the output, but i get an error when trying to press the button. here is the error: E 0:00:03:378 _process: Error setting property ‘text’ with value of type Nil.
label.gd:11 @ _process()
label.gd:11 @ _process()
label code:
extends Label
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
text = global.mem1
global code:
extends Node
var mem1
var mem2
var mem3
var mem4
var mem5
var mem6
var slot_1_locked = false
var slot_2_locked = false
var slot_3_locked = false
var slot_4_locked = false
var slot_5_locked = false
var slot_6_locked = false
var options: Array = [1, 2, 3, 4]
var Randomizedoptions: Array = [ ]
button code:
extends Button
func _on_pressed() → void:
if global.Randomizedoptions.is_empty():
global.Randomizedoptions = global.options.duplicate()
global.Randomizedoptions.shuffle()
global.mem1 = global.Ranomizedoptions
return global.options.pop_front()