#calling values in another script

1 messages · Page 1 of 1 (latest)

lunar anchor
#

does anyone know how i would call like a key if its stored in a different script

#

values from a dictionary and array

lament rainBOT
#

studio** You are now Level 8! **studio

hazy ivy
#

you could send the table trough a bindable event

lunar anchor
#

can u elaborate

#

do u have a code

formal fiber
#

or bindable events

#

do your own research on them

lunar anchor
formal fiber
#

if you have something that needs to be used in more than 1 script, it's general practice to put that into a module script

#

in this case, you'd move the function into a module script and then you can require that module script in the scripts you want to use the function in

lunar anchor
#

oh

#

can u explain how to do that]

formal fiber
vague scarab
#

📜Join my Discord Community if you want scripting help, give feedback, or just hang out:
https://discord.gg/WC6kPu5W5P

🔴Watch My Full Roblox ADVANCED Scripting Tutorial Series:
https://www.youtube.com/playlist?list=PLQ1Qd31Hmi3WKkVHnadvhOOjz04AuMYAf

🎨Watch My Full Roblox GUI Tutorial Series:
https://www.youtube.com/playlist?list=PLQ1Qd...

▶ Play video
lunar anchor
#

ik

#

i watch him

dry tartan
# lunar anchor i watch him

This is almost universally discouraged, but another quick way to share values across scripts is to use the _G global table to store them, for example:

Script A
_G.Key = "SDF09SDF"

Script B
print(_G.Key)

Just note the order in which you initialise and then read matters - if the line in script B runs before script A, it'll print nil. Also, it can quickly get polluted. So just be really careful. I'd recommend module scripts but I wanted to let you know about _G as well, though maybe I am a bad person for doing so...

hazy ivy
lament rainBOT
#

studio** You are now Level 10! **studio

vague scarab
#

to use _G