0 votes

So guys i need a little help in the game "Dodge The Creeps" so i just finished the game and i was fixing some problems and most of them i could but then i came to this that i just cant fix cause i dont have idea whats the problem,but it says "Invalid call to function 'game over' in base 'CanvasLayer'(HUD.gd)'. Expected 1 arguments".

Here is the code from HUD.

extends CanvasLayer

signal start_game

func show_message(text):
$MessageLabel.text = text

func gameover(text):
message("Game Over")
yield($MessageTimer, "timeout")
$MessageLabel.text = "Dodge The\nCreeps"

func update_score(score):
$ScoreLabel.text = str(score)

func onMessageTimer_timeout():

func onStartButtonpressed():

in Engine by (25 points)


1 Answer

0 votes
Best answer

The error is saying that the function 'game over' is not getting 1 argument when it's being called. For example, calling do_something() (note the missing argument) for the following function will produce the same error:

func do_something(arg):
by (91 points)
selected by

Thank you,i am begginer so still i dont know what to do.

When you run your game the debugger will tell you the script by name and the line which is throwing the error. Look beneath the ""Invalid call to function" error message and you'll see "Stack Frames". The script listed at the top is the script and line to repair. Next, find the gameover function on that line. It's missing a text argument. So, for example, it may read gameover() but it needs to be gameover("game is over"), or better yet gameover(my_text). Arguments are what's inside the parentheses which you provide to a function (or method) that you are calling.

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 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 webmaster@godotengine.org with your username.