r/Bitburner • u/sailrmouth72 • Sep 24 '24
Why won’t my script run?
I’m gonna preface this by saying I’m completely new to coding as a whole, so I actually just have no clue wtf I’m doing. Why won’t my script run? It’s completely just not working at all and I’m just confused, I’ve tried everything I could think of to get it to work (not much) and nada. I always get the same we’re message too, even when I did the men command.
6
u/nedrith Sep 24 '24
You have two main functions. I'm assuming you copied the second export async function main(ns) from someone else's code and placed it in a new file that already had a main function and now you have two.
When you copy and paste someone's code you either have to replace the entire file with it.
-2
u/sailrmouth72 Sep 24 '24
Oh, in the tutorial menu, they say to copy and paste the code into the script editor and that’s literally what I did.
2
u/HiEv MK-VIII Synthoid Sep 25 '24
They meant for you to replace what was already there with that code. So the problem was that you didn't remove the default code before pasting in the code you were supposed to be using.
3
u/ZeroNot Stanek Follower Sep 24 '24
even when I did the men command.
Try either help or mem. :)
As others have already pointed out, the error message tries to tell you.
Identifier
mainhas already been declared. (4:24)
The label main has been previously included in your program.
The error statement points to line 4, character (or position) 24. The line number is typically right, but position may be sometime off.
In your second image, you declare export async function main(ns) on line 2 and again on line 4.
1
u/sailrmouth72 Sep 24 '24
Ohhhh this is the most helpful anyone has been in these comments, I actually learned something new lol.
(when I said men command I meant mem, that was just my phones autocorrect, sorry lol)
21
u/Salanmander Sep 24 '24
Your script has two functions declared, both named "main". Is the fact that you have the "export async function main(ns)" line repeated deliberate?
Side note: it's better to do screen shots rather than photos, and if you're going to do photos at least make sure they're oriented so I don't have to turn my head sideways to read them.
10
u/HiEv MK-VIII Synthoid Sep 24 '24
Better yet, just copy the text and paste it into a Reddit "code block", that way you don't have to upload an image somewhere, and people can copy-paste and/or edit your scripts far more easily.
4
1
-11
u/not-cyber Sep 24 '24 edited Apr 24 '26
Wiped clean. Redact removed this post along with thousands of others. It also handles data broker removals so your personal info stops getting sold.
humorous shocking rock test nail blanket snatch yam sleep society
1
u/HiEv MK-VIII Synthoid Sep 24 '24
The issue isn't how to run a script, it's that this script can't be run at all, due to having two
main()functions.1
u/not-cyber Sep 24 '24 edited Apr 24 '26
This post was purged using Redact. I use it to mass delete social media content and remove my info from data brokers. All major social media platforms supported.
grey friendly thought tan skirt gaze unwritten school advise scale


15
u/drakkillen Sep 24 '24
r/shreenshotsarehard