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

Why won't this code work / save?

Asked by
StoIid 364 Moderation Voter
9 years ago

This is supposed to be a DataStore script I did from a tutorial but it doesn't seem to work. Any idea what's wrong?

Here's part one of the script:

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

Part 2, located in a seperate script

01local DataStore = game:GetService("DataStoreService"):GetDataStore("LolWhyDa")
02 
03 
04game.Players.PlayerRemoving:connect(function(player)
05 
06    local key = "user-"..player.userId
07    --Save key: {points, coins}
08    local valuesToSave = {player.leaderstats.Points.Value, player.leaderstats.Coins.Value}
09    DataStore:SetAsync(key, valuesToSave)
10 
11end)

both scripts are in ServerScriptService.

0
leaderstats must be a model lucas4114 607 — 9y
0
I did that, still didn't save! StoIid 364 — 9y

2 answers

Log in to vote
1
Answered by 9 years ago

I know thisis not much help but this is where you can learn it http://wiki.roblox.com/index.php?title=Data_store

0
It doesn't. I tried many things it shows and they still won't work for me. StoIid 364 — 9y
Ad
Log in to vote
0
Answered by
IrishFix 124
5 years ago

With data stores it is dificult, but as johndeer said, that is the best place to start :/

Answer this question