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

My DataStore Is Not Working To Save Players Leaderstats Any Way To Fix This?

Asked by 2 years ago

So im having trouble with saving players leaderstats and im kind of new to datastores and note I was watching thedevkings video so idk what I did wrong.

01local plr = game:GetService("Players")
02local DSS = game:GetService("DataStoreService")
03local MyData = DSS:GetDataStore("MyData1") -- gets a data store and you can name it
04--- plr name
05plr.PlayerAdded:Connect(function(player)
06    print(player.Name)
07    local text = game.StarterGui.ScreenGui.TextLabel
08    text.Text = player.Name
09    --- leaderstats
10    local leaderstats = Instance.new("Folder")
11    leaderstats.Name = "leaderstats"
12    leaderstats.Parent = player
13    local Coins = Instance.new("IntValue")
14    Coins.Name = "Coins"
15    Coins.Parent = leaderstats
View all 45 lines...
1
Just wanted to add that the `while true do` loop in your script completely stops the rest of the script from executing. DindinYT37 246 — 2y

1 answer

Log in to vote
1
Answered by 2 years ago
Edited 2 years ago

There's a lot of problems in your script that I'm too lazy to list all. Here's the script, just observe this script and the previous one to learn your mistakes.

01local plr = game:GetService("Players")
02local DSS = game:GetService("DataStoreService")
03local MyData = DSS:GetDataStore("MyData1") -- gets a data store and you can name it
04local RunService = game:GetService("RunService")
05 
06local function waitForRequestBudget(requestType: Enum.DataStoreRequestType)
07    local currentBudget = DataStoreService:GetRequestBudgetForRequestType(requestType)
08 
09    while currentBudget < 1 do
10        currentBudget = DataStoreService:GetRequestBudgetForRequestType(requestType)
11        task.wait(5)
12    end
13end
14 
15function loadData(player)
View all 90 lines...
Ad

Answer this question