© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
9 replies
cuhpl

❔ Hi,my flappy bird game script isnt working

The script in making is to show that the score counter incrreases when the gamobject(bird) collides with the trigger inbetween the pipes but it isnt working
can someone check if its my script that is wrong or idk

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

public class logic : MonoBehaviour
{
    public int playerscore;
    public Text score;

    [ContextMenu("IncreaseScore")]
    public void addScore()
    {

        playerscore = playerscore + 1;
        score.text = playerscore.ToString();

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

public class logic : MonoBehaviour
{
    public int playerscore;
    public Text score;

    [ContextMenu("IncreaseScore")]
    public void addScore()
    {

        playerscore = playerscore + 1;
        score.text = playerscore.ToString();

    }
}


this script is to increase the score

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

public class middlescript : MonoBehaviour
{

    public logic logic;
     
    // Start is called before the first frame update
    void Start()
    {
        logic = GameObject.FindGameObjectWithTag("logic").GetComponent<logic>();
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        logic.addScore(); 
    }
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class middlescript : MonoBehaviour
{

    public logic logic;
     
    // Start is called before the first frame update
    void Start()
    {
        logic = GameObject.FindGameObjectWithTag("logic").GetComponent<logic>();
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        logic.addScore(); 
    }
}


this script is to communitcate to the script above and to add score whenever the gameobject collides with the trigger
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Flappy bird tutorial - game makers toolkit - sceneManagement, not calling.
C#CC# / help
3y ago
❔ My toolbox isnt working
C#CC# / help
3y ago
❔ i recreate flappy bird with unity, but i have a problem
C#CC# / help
3y ago
Code isnt working
C#CC# / help
12mo ago