need help with a clicker

so i want to make a clicker but when it shows the debug log its always 85 no matter what even if i hit w

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class score : MonoBehaviour
{
    public float scr = 0;

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey("w")) { scr += 1; }
        Debug.Log(scr);
    }
}

I’m not sure if GetKey requires lowercase or uppercase - regardless, if you use KeyCode.W instead, you don’t have to worry about which one it takes.

You also want GetKeyDown for this, not GetKey - GetKey will cause this to add 1 every frame that W is held.

2 Likes