HELP its been about a month my game is delayed cuz the datastore error
Can somebody fix my code to work, im trying to make a DataStore for Cash
link to repost: https://scriptinghelpers.org/questions/107002/data-store-error-plz-help-repost
Output: DS isn't a vaild part of DataModel
Thanks to anybody who fixes it!
01 | local DS = game:GetService( "DataStoreService" ) |
02 | local CurrencySave = game.DS:GetService( "FirstStore" ) |
03 |
04 |
05 | game.Players.PlayerAdded:Connect( function (player) |
06 |
07 | local leaderstats = Instance.new( "Folder" , player) |
08 | leaderstats.Name = "leaderstats" |
09 | leaderstats.Parent = player |
10 |
11 | local cash = Instance.new( "IntValue" , leaderstats) |
12 | cash.Name = "Fruit" |
13 | cash.Value = 100 |
14 |
15 | local data |
You are trying to find a child in game
called DS
and there is no such thing. You already defined the variable so, you don't need to get the Parent
again.
Change line 2 to:
1 | local CurrencySave = DS:GetService( "FirstStore" ) |
WAIT!!
We're not done. Another error on line 2 is that you are saying :GetService()
. This can only be done on game
. You are trying to get a service in a service. It just doesn't make sense.
It should be:
1 | local CurrencySave = game.DS:GetDataStore( "FirstStore" ) |
We're still not done.
You just added the IntValue Cash
in the leaderstats
but, on line 31, you said:
1 | player.leaderstats.Fruit.Value |
I think what you meant was:
1 | player.leaderstats.Cash.Value |
If it wasn't what you were trying to do, then please let me know.
Okay, that's it, sir!
I hope this works and make sure to accept this answer if it does!
If it doesn't, then please tell me what errors you are getting in the output.
This code is destined to work.
01 | local DS = game:GetService( "DataStoreService" ) |
02 | local CurrencySave = DS:GetDataStore( "FirstStore" ) |
03 |
04 |
05 | game.Players.PlayerAdded:Connect( function (player) |
06 |
07 | local leaderstats = Instance.new( "Folder" , player) |
08 | leaderstats.Name = "leaderstats" |
09 | leaderstats.Parent = player |
10 |
11 | local cash = Instance.new( "IntValue" , leaderstats) |
12 | cash.Name = "Fruit" |
13 | cash.Value = 100 |
14 |
15 | local data |