I have problem with my variable/

Basically, script is supposed to debug log and say “Hello” when “speed” variable reaches 200.
Script just doesn’t work and dont debug the console do not say “Hello”. I procceded to try to fix it, find in google a fix for my problem, but nothing seem to be working. Hope somone can say what i did wrong, and how i can fix it. Thanks (im scripting like for a week, sorry if this is some dumb question that most of u can do in couple of minutes)

Heres the script:
{
Public int Speed = 200:

{
if.Speed = 200
debug log(Hello);
}
}
Heres the communicates that show up in the console:
Assets\Variables.cs(5,1): error CS1022: Type or namespace definition, or end-of-file expected
Assets\Variables.cs(6,5): error CS0116: A namespace cannot directly contain members such as fields or methods
Assets\Variables.cs(6,26): error CS1002: ; expected
Assets\Variables.cs(6,26): error CS1022: Type or namespace definition, or end-of-file expected
Assets\Variables.cs(9,12): error CS0116: A namespace cannot directly contain members such as fields or
methods
Assets\Variables.cs(9,17): error CS1022: Type or namespace definition, or end-of-file expected
Assets\Variables.cs(10,24): error CS1001: Identifier expected
Assets\Variables.cs(11,5): error CS1022: Type or namespace definition, or end-of-file expected
Assets\Variables.cs(12,1): error CS1022: Type or namespace definition, or end-of-file expected
Assets\debug log lmao.cs(7,20): error CS1002: ; expected

Please, try to open topics when you are seeking for real advice. We cannot help you to learn how C# should be written.
If you want to learn the basics, there are great tutorials out there. For example this one:

https://www.youtube.com/watch?v=sQurwqK0JNE

Or you can find other ones on YouTube or on Udemy or such portals. Working in Unity requires basic C# understanding if you want to do scripting.

Also if you post on these forums, please put your code in code tags as it is described here:
https://discussions.unity.com/t/481379

2 Likes

Thanks for advice :smile:

check it(speed == 200)

not speed = 200

If only that was the only problem with that “script”…

1 Like