I'm getting this error: the modifier public is not valid for this item

So I’m trying to add a simple jump button by making my jump scripting public but i keep getting the error: the modifier 'public 'is not valid for this item
Here Is My Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HeroCharacterController : MonoBehaviour
{
[SerializeField] private float jumpHeight = 10f;
[SerializeField] LayerMask groundLayers;
[SerializeField] private float runSpeed = 8f;
[SerializeField] private AudioClip jumpSoundEffect;

public PlayerController player;
private float gravity = -50f;
private CharacterController characterController;
private Animator animator;
private Vector3 velocity;
private bool isGrounded;
private float horizontalInput;
private bool jumpPressed;
private float jumpTimer;
private float jumpGracePeriod = 0.2f;
public float jumpSpeed = 5;

// Start is called before the first frame update
void Start()
{
characterController = GetComponent();
animator = GetComponent();
player = FindObjectOfType();
}

// Update is called once per frame
void Update()
{
horizontalInput = 1;

// Face Forward
transform.forward = new Vector3(horizontalInput, 0, Mathf.Abs(horizontalInput) - 1);

// IsGrounded
isGrounded = Physics.CheckSphere(transform.position, 0.1f, groundLayers, QueryTriggerInteraction.Ignore);

if (isGrounded && velocity.y < 0)
{
velocity.y = 0;
}
else
{
// Add gravity
velocity.y += gravity * Time.deltaTime;
}

characterController.Move(new Vector3(horizontalInput * runSpeed, 0, 0) * Time.deltaTime);

// Jumping
jumpPressed = Input.GetButtonDown(“Jump”);
if (jumpPressed);
{
jumpTimer = Time.time;
jumpTimer = -1;
}

if (isGrounded && (jumpPressed || (jumpTimer > 0 && Time.time < jumpTimer + jumpGracePeriod)))
{
velocity.y += Mathf.Sqrt(jumpHeight * -2 * gravity);
if (jumpSoundEffect != null)
{
AudioSource.PlayClipAtPoint(jumpSoundEffect, transform.position, 0.5f);
}
}

public void jump()
{
player.Jump = true;
}

// Vertical Velocity
characterController.Move(velocity * Time.deltaTime);

// Run Animation
animator.SetFloat(“Speed”, horizontalInput);

// Set Animator IsGrounded
animator.SetBool(“IsGrounded”, isGrounded);

// Set parameter for JumpFall Blend Tree Animation
animator.SetFloat(“VerticalSpeed”, velocity.y);
}

}

Any help is greatly appreciated :slight_smile: !

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

How to understand compiler and other errors and even fix them yourself:

Beyond that, here is how to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220