- Home /
unexpected char: 'S'.
I am creating a fps game with my friends and I got this script from the internet and added some lines of code to make ammo but unity say's unexpected char: 'S'.
Here is my code please help me fix this. :)
var projectile : Rigidbody;
var speed = 20;
var Ammo = 30;
function Update () {
if ( Input.GetButtonDown ("Fire1")) {
Ammo --;
if (Ammo <=0.String)Destroy (GameObject);
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection( Vector3 (0, 0, speed));
audio.Play();
Destroy (clone.gameObject, 3);
}}
Please only post questions once, not seven times. Until you have 15 $$anonymous$$arma points (earned by asking and answering questions), all your posts will go through moderation. Sometimes it can take several hours before a script will appear on the list.
Look at line 9. Your error message should have directed you to this line of code as well.
0.String ??
@Beron_Vengeous02 - here's a Pro tip. When you declare variables tell the compiler what the type of the variable is. So, for example Ammo
is probably meant to be an integer. That way you can simply say if (Ammo < 0)
. There are tons of online tutorials that'll $$anonymous$$ch you how to program.
Thanks Guys but I have a really funny story...
I have already fixed it but thanks anyway. :)
@Beron_Vengeous02 Please post an answer describing how you fixed it. You should also then mark it as correct.
Your answer
![](https://koobas.hobune.stream/wayback/20220613135135im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
ammo count help 1 Answer
how do i make a ammo and reload system 1 Answer
Fps Ammo pickup problem(programming noob) 1 Answer
how do i attach a gun to my character 2 Answers