How to I switch my sprite tint randomly

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

I want to change a simple white sprite to either red or bleu on start. I guess I would need to set the two tint options as an array and assign one of the two color values randomly using rand in the _ready function. Could someone show me what that code would be or if the is a better way?

:bust_in_silhouette: Reply From: jgodfrey

Untested, but something like this should work (assuming the script is associated with the sprite itself):

func _ready():
	var colors = [,]
	self_modulate = colors[randi() % colors.size()]