0 votes

Hi! I'm new to Godot and GDScript and I'm making my own Minecraft rip-off for fun! I want to do the splash text thing from the game but I need the randomiser method but I don't know how to declare it, Here's my code

extends Label

# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var splashvar = 1

# Called when the node enters the scene tree for the first time.
func _ready():
randomise (splashvar)

# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
#   pass

Please help
P.S I will do an If statement for the list of text

Godot version 3.3.2
in Engine by (15 points)
edited by

1 Answer

+1 vote
Best answer

What are you trying to do?

There is a function is called randomize() but it takes no arguments:


That function is used to initialize (seed) the random number generator.

by (21,714 points)
selected by

I want to randomize the "splashvar"
Oh and it says randomise() in the built in docs

Where in the docs, because it's always been spelled this way:
enter image description here

To assign a random value to a variable, you need to generate a random number. You can do that with randi() if you need an integer, or rand_range() if you need a float.

Ok, I must of read it wrong, TY!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.