The goal that I want to achieve with this is to have a car spawner that will take your money away when you purchase a car.
The issue is that when I purchase a car, the money used to purchase said car does not decrease on the leaderstats. Lets say I have $100,000 and the car I want is $70,000. If I were to purchase that car, my initial money doesn’t decrease at all.
I have tried to rework the leaderstat positions and names, as well as the setup of how it’s scripted. Nothing I’m trying is working.
So if I were to replace “plrMoney” with something like
“ourPlayer.leaderstats.Money.Value = ourPlayer.leaderstats.Money.Value - price”
I would think that would help my problem. But the problem continues. This is the first time I’ve ever gotten into datastore scripting and stuff, so I’m honestly clueless with all of this
Don’t worry, scripting is kinda hard to learn. FireServer() automatically passes over the Player instance that uses it, which you have already acknowledged and specified as “plr”. Simply replace “Player” with “plr” and you’re good to go.
Alright, so I just ran a couple tests. I added a few more areas in the script where it’ll print a message. Where it says print("Pre-Buy"), that is the last line that is run before there’s an error. The error occurs with the if-statement on leaderstats
So with this system, theres a few different scripts. There’s a script in serverscriptservice, and that’s the one that I’ve been working on with the whole plr vs player and localplayer topic. Theres a module script within a GUI in a clickpart, and thats where the veh[number]'s are.
Alright so, I tried purchasing two cars. One car was worth $0, and the other was worth $20,000. The free car purchased perfectly fine, and saved to my player. The $20,000 dollar car did not purchase, and did not save to my player.
Here’s a screenshot of the output:
At the bottom, where it says “20000”, that’s the print of print(price) (price = veh)