Verry simple script not working...

Hello!
Before you say stuff like ‘omg noob u cant script for [Insert Rude word here]’.
Im absolutly not a good scripter.
This script has a lots off error.

if Input.H 

do Siren.Mute=false



if Siren.Mute=false

do Siren.Mute=true



if Siren.Mute=true

do Siren.Mute=false

(I used Java Script)

Thanks for helping me out!

http://unity3d.com/support/documentation/ScriptReference/Input.GetKeyDown.html
http://unity3d.com/support/documentation/ScriptReference/AudioSource.html

And its

if (something) {
    Code Here!
}

Oh, and now that I helped you…

omg noob u cant script for a swizzlestick! :stuck_out_tongue:

lol , thats pretty moraly uplifting…

haha :stuck_out_tongue:

You clearly have very little understanding of how javascript and unity work.

I would suggest working through these youtube tutorials.

they are great for new scripters.

Those who give insults do so with ignorance. They’ve forgotten what it was like to be a beginner. Inputs for keys are as follows: if (Input.GetKey(“H”)){ . I tried that and it doesn’t work but not because of the format but because I haven’t made an “H” input assignment in the input settings.

Hello, sorry for the late message.
I follow evrything you guys said.
But now my oeput says this.
'Exptecting { , found ‘Siren’. In line 3,4
Also here is my updated script.

if (something) {

if (Input.GetKey("H"))

do Siren.Mute=false



if Siren.Mute=false

do Siren.Mute=true



if Siren.Mute=true

do Siren.Mute=false

}

Bump…

if (Input.GetKeyDown ("H")) { // GetKey returns true as long as the key is down, GetKeyDown returns first frame only
    Siren.mute = !Siren.mute;  // ! operator returns opposite
}

Assuming Siren is an AudioSource.

the normal and correct way to make an if statement work is like this:

if(condition){
   //do stuff
}

so your code will be all like! (note: this will un-mute your siren when you hold down H key)

if ((Input.GetKey("H")){
	Siren.Mute = false;
}
else{
	Siren.Mute = true;
}

most of your code doesn’t make sense, seriously, i am not trying to be rude or anything, but look at your logic:

If you press H you unmute your siren, afterwards you check if it has been unmuted to mute it back, and since that was not enough you check again if you just mute the damn siren, to unmute it AGAIN!!!

:)) funny code is funny.

Explain what are you trying to do, i might be of help.