0 votes

I am trying to put a setter, but don't know why keep getting this error. It is a standard line of code, can not figure out what is the problem. Did I do anything wrong? Thank you.

expected end of statement after expression, get setget instead

var count = 12 setget setter
Godot version v3.2.3
in Engine by (260 points)

I believe it's missing a comma at the end to indicate that you want a setter but not a getter:

var count = 12 setget setter,

2 Answers

0 votes

Hi,
this line of code is perfectly fine. Are you sure this is the line of the error?

by (4,014 points)

Thanks for answering my question. It is weird, somehow it keep telling me the error, but I have no problem with setget on other parts of my project. Anyway, I end up using another approach to achieve the intent result without using setget.

0 votes

You code is not file. You should write:

var count = 12 setget setter

func setter(value: int) -> void:
count = value

You have to write a function for the setter

by (86 points)
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.