When I try to use the GDScript code below, Godot gives me the error:
error(3, 34) Error parsing expression, misplaced: Built-In Func Why am I getting this error, and how can I fix it? Thank you in advance) func _on_MoneyTimer_timeout(): var money_scene = load("res://Money.tscn").instance() money_scene.position = Vector2((randi % 0 + width_project), (randi % 0 + height_project)) add_child(money_scene)
error(3, 34) Error parsing expression, misplaced: Built-In Func Why am I getting this error, and how can I fix it? Thank you in advance)
func _on_MoneyTimer_timeout(): var money_scene = load("res://Money.tscn").instance() money_scene.position = Vector2((randi % 0 + width_project), (randi % 0 + height_project)) add_child(money_scene)
Which line produces the error message?
Is randi declared as a variable? If you're trying to use it as a function, it needs parentheses: randi()
randi()
DaveTheCoder Yes sir! It was my stupid mistake. Thank you!
Also, randi() % 0 is asking for the remainder upon division by zero, which would be an illegal operation.
randi() % 0