I made these two scripts that have no errors on them and I checked the tags a dozen times everything seems fine but the score is not updating. Can Someone please help, I added these scripts to two empties
Sounds like you wrote a bug… if you post the code properly in the forum (see the button at the top of the editing window), perhaps we can have a look.
Meanwhile, time to start debugging!
By debugging you can find out exactly what your program is doing so you can fix it.
Use the above techniques to get the information you need in order to reason about what the problem is.
You can also use Debug.Log(...);
statements to find out if any of your code is even running. Don’t assume it is.
Once you understand what the problem is, you may begin to reason about a solution to the problem.
As has been pointed out… the score isn’t updating because you have a bug in your code. Either it isn’t being called, one of your conditions is not being met or something else entirely. Check your assumptions starting at the root and work out from there.
Can anything increase the score? Skip all the code that has a dozen if conditions. If that doesn’t work there is something obvious that is broken, if it does then likely one (or all) of your conditions are failing and nothing updates the value.
Note that among other things you actually check whether the text property is null. That should hardly be necessary as it won’t be when it is working AND if it is you don’t want a silent failure. The score in such a case wouldn’t update on the screen BTW. You want it to fail dramatically so you can set the reference.
I posted both codes in pastebin link, I added a debug it’s not showing
Hey, if you want people to gaze at your code, it’s all up to you to follow forum rules posting.
Then better find out why it’s not running.
See steps above about debugging.
I thought since it’s broken code it would be worth posting because I thought someone here could help me. I am getting no errors
Perhaps it isn’t obvious but the way someone would help you is by doing the research we have suggested that you do. We aren’t going to download the code, drop it into a project and debug it (probably). You would have the answer already (and have gained valuable experience) if you simply try to debug your issue.
The debug is supposed to show when a sphere is touching a piece of land, when I drop it on the land nothing is showing up how much more simply can I explain the problem. I checked the tags I checked the debug and no errors come up so it must be the code is missing something. If you can’t help then stop wasting my time by telling me to do research I’ve already done, that’s how I got the code
If you aren’t seeing any script errors in the console, I’d say it’s more likely something in your scene simply hasn’t been set up correctly. For example, are you certain the script(s) are attached to the correct objects?
Then as I have already suggested, post the code as specified in the forum rules.
As long as it is off on pastebin, I’m certainly not looking at it. Most other people here probably won’t bother to go wiggle pastebin’s dirty buttons, and besides you probably just pasted the entire thing in without taking the time to say “Hey, it gets to line X and the values are Y and Z but I expected them to be A and B.”
But hey, up to you.
maybe u havent added rigidbody or something to detect the collision or trigger . did u try that