why do i get quack in my script

this is my inventory script. it was working until i added this to it. “this is not full script just the part that is giving me problems”

var mainCamera = FindCamera();
var direction = mainCamera.transform.TransformDirection(Vector3.forward);
var hit : RaycastHit;
function Update (){
	
	
	if (Input.GetMouseButtonDown (0) && !clicked){
	
		
		if (Physics.Raycast (mainCamera.transform.position, direction, hit, 5)){

			if (hit.gameObject.GetComponent.<pickupAnimation>() && !clicked){
				hit.gameObject.GetComponent.<pickupAnimation>().isMoving = true;
				clicked = true;
			}
			if (hit.GetComponent.<EvoLight>() && mainCamera.GetComponent.<Invintoiry>().TinderBox > 0 && !clicked ){
			   hit.GetComponent.<EvoLight>().on = true;
			   mainCamera.GetComponent.<Invintoiry>().TinderBox --;
			   clicked = true;
			}
			if (hit.GetComponent.<Door>()){
			
			}
			if (hit.GetComponent.<Rigidbody>()){
				AimImgHolder.sourceImage = HandHoldImg;
			}
	
		} 
	}
	else{
		clicked=false;
		
	}
	
       
	if (Physics.Raycast (mainCamera.transform.position, direction, hit, 5) && !clicked){

			if (hit.GetComponent.<pickupAnimation>()){
				AimImgHolder.sourceImage = handGrabImg;
			}
			if (hit.GetComponent.<EvoLight>() && mainCamera.GetComponent.<Invintoiry>().TinderBox > 0 ){
			   AimImgHolder.sourceImage = TinderBoxImg;
			}
			if (hit.GetComponent.<Door>()){
				AimImgHolder.sourceImage = DoorImg;
			}
			if (hit.GetComponent.<Rigidbody>()){
				AimImgHolder.sourceImage = handGrabImg;
			}
	
		} 
[CODE]

What is the problem you’re running into?

all my .GetComponent. in this part give me the quack error. the rest of my .GetComponent. after the section i posted work fine. idk why.

What on earth is the “quack error”?

Assets/Project root/Prison Player/Scripts/Hand.js(29,57): BCE0138: ‘quack’ is not a generic definition.

this is more of a interact script for my inventory script. it is the players hands. basically.

Bizarre, I had no idea Unity had an error message like that.
Looking it up, it seems have something to do with a variable being used in the wrong way - maybe a reference to duck-typing?
Which line of code does that message correspond to?

yes it is duck-typing. but idk what i did to get it. all the lines with get Component.

RaycastHit is a struct, it doesn’t have GetComponent. It doesn’t have .gameObject either, so I’m surprised you’re not getting a compile error for that.

I think you want hit.transform.GetComponent

well it worked but idk why.
this is what my other scripts have and they do not give the error

if(hit.GetComponent.<Collider>()){
            hit.GetComponent.<Collider>().SendMessage("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
[CODE]

thank you this was driving me nuts. i did not know what to do. thank you very much.

I would recommend switch to C#. US is on it’s way out.

sadly i only know js. idk why unity is doing away with it. it works.

They wrote a detailed blog post about it, worth checking out.

Your script looks very close to what it would look like in C#. However, everytime your GetComponent is followed by a period (“.”) which is incorrect (at least in C#).

hit.GetComponent<Door>() // not hit.GetComponent.<Door>() for example

That period is correct for US. I don’t like it though, I much prefer the C# variant.

Okay :slight_smile: