using UnityEngine;
public class Projectile : MonoBehaviour
{ public float damage = 1f;
public float IPForce = 30f;
private float speed = 0f;
public float bulletspeed = 4;
Hi and welcome.
Before i address your problem, please consider the following:
Use code tags to post code examples. Adds proper formatting and syntax highlighting. Makes it easier to help you. If you dont know how to use code tags, there is a sticky forum post on this subforum explaining how.
Always add the full error message if you have problems with an error. This includes the line the error is thrown, and should the example not include the full script, i would also expect you to tell us what line in the posted example this refers to.
A little description of the problem usually also helps.
With that out of the way, in line… whatever that is. See? Makes it quite hard to help
Anyways, you write blah.GetComponent(). This returns you the component of type ‘target’ on the GameObject ‘blah’. You never save this anywhere tho. So what you probably intended to do is write 'Target target = blah.GetComponent();. On that note, class names like ‘target’ should start with a capital letter (look up some naming conventions).
So currently you write target.TakeDamage(), but the programm has no idea what ‘target’ is since you did never define it. Thus it tells you that it expects an identifier (the name of a variable) there. With the suggestion above, you would now actually have a variable with the identifier ‘target’, so this problem at least should be fixed.
Ok so, with what @davidnibi just posted, you actually need to fix these two problems for it to work.
When you write ‘void OnCollisionEnter’ your IDE should normally already offer you the autocompletion, since OnCollisionEnter is a function which is defined in MonoBehaviour and you just fill it with some content.
Since you seem to be very new to programming, i can generally recommend this tutorial series on C# & Unity:
Tutorials Playlist