How to make a global variable of player.leaderstats.Gold.Value

Hello everyone,

I am sure someone knows how to do this very simple, but when I tried a few different ways of making a global variable it gives errors, various errors because nothing I tried works. Some say infinite yeild, some say attempt to index nil, its kinda weird I just missing something.
I can declare the variables in the function because it has the paramiter (player) but obviously I am missing something. Please let me know how I can achieve this as it would save coding a lot for me.
Sure I cna copy and waste the variables in each function, but I have a lot of functions and the code would look so great if it just limited the amount fo times I have to type player.leaderstats.Gold.Value…

Thanks whoever knows haha sorry if this is simple question.

Assuming you just want to use it to have Variables be accessed in function, Try using a ModuleScript with something called Object Oriented Programming

1 Like

Ahh okay, looking at it now thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.