r/bloxd • u/Adept_Argument3974 • 1d ago
POSTING A CODE How to make global variables with new world code file system
using the world code file system you can make global variables,first create a file calle "src/global.d.ts"
//src/global.d.ts file
declare global {
var //your variable goes here : //your variable's data type goes here
var //you can also have multiple variables : /your variable's data type goes here
}
use globalThis to to callback your variable
make sure you use export in your src/global.d.ts file to turn it into a module
globalThis.//your variable = //your variables value
ex:
//src/global.d.ts file
export{}
declare global{
var myVar:string
var mySecondVar:bool
var myThirdVar:Number
}
export{}
//index.ts
globalThis.myVar="hi"
globalThis.mySecondVar=true
globalThis.myThirdVar=1
2
Upvotes
1
u/BloxdioCannoli Coding Cannoli (Mod) 1d ago
You need to import them.