void Update wont work

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class Score : MonoBehaviour
{

    public Transform Player;
    public TextMeshProUGUI scoreText;

    void Update()
    {
        scoreText.text = Player.position.z.ToString("0");
    }
}

i have a few other scripts and unity gives me errors saying im already using update in another script, i tried making them public/private but that didn’t work

using UnityEngine;

public class FollowPlayer : MonoBehaviour
{


    public Transform Player;
    public Vector3 offset;

    void Update()
    {
        transform.position = Player.position + offset;
    }

}

I’m new, so I don’ get what’s exactly wrong here

Here’s the error:
Assets\Scripts\Score.cs(12,18): error CS0111: Type ‘Score’ already defines a member called ‘Update’ with the same parameter types… Type ‘FollowPlayer’ already defines a member called ‘Update’ with the same parameter types…

Sounds like you maybe duplicated your scripts or duplicated an entire folder structure containing scripts.

If you insist on making two scripts with the same name, use namespaces to differentiate them.

2 Likes

This is odd. I don‘t see an issue. Each script is in its own file? Are there multiple Score etc classes?

Yeah

I’m 100% sure I didn’t

Yeah this is either two methods with the same name or two classes with the same name. Try moving the scripts into their own namespace, and then reference the namespace in scripts that rely on these scripts and see what happens. If it solves the problem then you have two classes of the same name.

https://docs.unity3d.com/Manual/Namespaces.html

1 Like

Be careful with 100% certainty, it almost never exists -.- We are 90% certain that you do already have a class with the name Score in the global namespace. Note that this class could be in a precompiled assembly or a package you installed. We don’t know what you have in your project.

Since both your Score and your FollowPlayer script are affected, is it possible that you created a build of your game INTO your assets folder? That would place the compiled managed DLLs inside your project.

Though it’s hard to tell with that little information.