Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

HELP WITH DATA STORES? [WONT WORK, PLEASE HELP!]?

Asked by
Oficcer_F 207 Moderation Voter
6 years ago
Edited 6 years ago

ERROR: Attempt to index local 'savedValues' (a number value)?

01DataStore = game:GetService("DataStoreService"):GetDataStore("PeasStore")
02 
03 
04game.Players.PlayerAdded:connect(function(player)
05 
06local stats = Instance.new("IntValue", player)
07stats.Name = "leaderstats"
08 
09local points = Instance.new("IntValue", stats)
10points.Name = "Points"
11 
12local coins = Instance.new("IntValue", stats)
13coins.Name = "Coins"
14 
15local key = ("player-" .. player.UserId)
View all 31 lines...

Error at line 19

``PLEASE HELP ME!

0
Line 22. You make a table with curly braces {} not brackets () User#19524 175 — 6y
0
Still doesnt work. Oficcer_F 207 — 6y
0
try dis: points.Value = savedValues[1] , coins.Value = savedValues[2] mixgingengerina10 223 — 6y
0
That is what I wrote.. Oficcer_F 207 — 6y
View all comments (5 more)
0
No commas... See before you judge mixgingengerina10 223 — 6y
0
So? Did it work or what? mixgingengerina10 223 — 6y
0
Hello?? mixgingengerina10 223 — 6y
0
I will try. But how will I write it? Oficcer_F 207 — 6y
0
I wrote it with commas, and on the same line. But I just got an error. Thanks for the help anyways! :) Oficcer_F 207 — 6y

1 answer

Log in to vote
1
Answered by
zblox164 531 Moderation Voter
6 years ago
Edited 6 years ago

You need to save when the player leaves the game too. I also added some things to the script that will help.

Try this:

01-- Define variables
02local DataStoreService = game:GetService("DataStoreService")
03local Players = game:GetService("Players")
04 
05-- You should put your data store as a separate variable then the service one
06local DataStore = DataStoreService:GetDataStore("NameHere")
07 
08-- Loads the data back to the player
09local function Load(plr)
10    -- Creates the stats
11    local leaderstats = Instance.new("Folder")
12    leaderstats.Name = "leaderstats"
13    leaderstats.Parent = plr
14 
15    local points = Instance.new("IntValue")
View all 63 lines...

I know it may look intimidating since it has 63 lines but it's just an upgraded version to what you had. Also make sure you have datastore enabled for your place. If you don't you can enable it by going to your place and clicking on the tree dots. Next press configure this place. Click on Games. Then press the Allow this place to be updated using the Save Place API in your game. checkbox.

Hope this helps!`

0
Could you explain what the ';' does at line 53? Thanks! Oficcer_F 207 — 6y
0
Semi-colon Oficcer_F 207 — 6y
0
The semi colon does the same thing as a comma in this case. You can use commas instead of the semi colon (in this case). zblox164 531 — 6y
0
Ok thanks! Oficcer_F 207 — 6y
View all comments (2 more)
0
Could you please edit out the pcalls, they seem to not work for me. Then I will accept the answer, thanks! Oficcer_F 207 — 6y
Ad

Answer this question