How to add a leaderstat with a space inside of it!

  1. What do I want to achieve? Keep it simple and clear!

So! I am trying to add my leaderstat to a script but! My leaderstat has a space inside of it.

  1. What is the issue?

local coins = pl.leaderstats.Blocks Mined if I put a space inbetween Blocks Mined then I get an error because it needs to be together.

  1. What solutions have I tried so far?

I’ve looked for a fix and haven’t found one.

Thank you for reading this and have a good day!

W a i t w h a t, could we see the script if possible?

It’s only 1 line that needs the fix. So basically you see on games like uhh… Bubble Gum Simulator their stats are Bubbles Blown. Which a space I’m trying to add a space to mine.

local coins = pl.leaderstats.Blocks Mined

Thank you

-Clzxwork

Try using Blocks_Mined

thirty cars

I will try this right now.

-Thank you

Clzxwork

1 Like

Ooooh I see

Yeah it’s possible, you can easily just do:

local coins = plr.leaderstats["Blocks Mined"]

Just be sure to encase any objects that have spaces/special symbols on them with brackets & quotation marks!

2 Likes

Omg thank you so much. I am new to scripting. Have a great day

-Clzxwork.

1 Like

Ah yeah it’s completely fine! Everyday you learn something new after all! Even if you were to do this:

local FunnyMeme = workspace["According to all known laws of aviation, there is no way a bee should be able to fly"]

print(FunnyMeme.Name)

It would still work! :sweat_smile:

Thank you so much! This has been a big help, Enjoy your day.

-Clzxwork

1 Like

Another option is the :FindFirstChild and :WaitForChild functions. The first function has nearly the exact same functionality as using workspace[name], however WaitForChild pauses the script until it finds the instance. It is highly recommended that you use WaitForChild at the beginning of scripts, as there is no guarantee as to when an instance will load up. However only use WaitForChild when you are uncertain whether the instance exists yet. If it does not find the instance, it will spit out an error.