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

I'm having trouble with a leaderboard and datastore variables, can someone help?

Asked by 7 years ago

Title: I'm having trouble with a datastore and leaderboard, I'm a beginner at datastore, can some please help?

ServerScriptServiec.leaderstats:18: attempt to index local 'saved' (a nil value)

01local datastore = game:GetService('DataStoreService'):GetDataStore("Friends")
02 
03game.Players.PlayerAdded:connect(function(player)
04        local leaderstats = Instance.new("IntValue", player)
05        local friends = Instance.new("IntValue", leaderstats)  
06 
07        leaderstats.Name = 'leaderstats'
08        friends.Name = "Friends"
09 
10        local uniquekey = "friends-"..player.userId
11        local pointsvalue = player.leaderstats.Friends.Value
12        local saved = datastore:SetAsync(uniquekey, pointsvalue)       
13 
14 
15        if saved then
View all 31 lines...
0
You save and load data through the data store. You are trying to save it through the value returned from a data store. User#5423 17 — 7y
0
Could you explain that? I'm not exactly sure what you mean by that. StarMarine614Classic 14 — 7y

Answer this question