Using file system (fs) in custom script

Hello everyone.
I am working on a project which requires me to store the number of times a certain button inside the scene is clicked in a file on server. I am trying to use “fs” in typescript for this but it keeps telling me that “require is not defined” .
I am still very new to both needle and typescript so I will very much appreciate any help.
Thank you.

Original Post on Discord

by user 1041936873012080670

Hey, you can not access the filesystem from a clientside script (unless you’re using a PWA or something like it) - what you can do is save information in the browser’s storage. Have a look at Client-side storage - Learn web development | MDN

Another way would be to send that information to the server / backend. If you’re planning to deploy to e.g. glitch using our template you could just save it using the networking API

You can find some information about that here: Networking | Needle Engine Documentation

@marcel :cactus: Thanks. I will look through these :+1: .

by user 1041936873012080670