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

Why Is my script for data Store is not working I need someone to explain?

Asked by 4 years ago
Edited 4 years ago

Here is my script.

01--Locals
02local DataStoreService = game:GetService("DataStoreService")
03local MyDataStore = DataStoreService:GetDataStore("MyDataStore")
04 
05--Stats adder
06game.Players.PlayerAdded:Connect(function(player)
07    local leaderStats = Instance.new("Folder")
08    leaderStats.Name = "leaderstats"
09    leaderStats.Parent = player
10 
11    --Cash stats
12    local Cash = Instance.new("IntValue")
13    Cash.Name = "Cash"
14    Cash.Parent = leaderStats
15    -- Load Data
View all 44 lines...
0
What is not working exactly? rabbi99 714 — 4y

2 answers

Log in to vote
0
Answered by
MediaHQ 53
4 years ago

I have a solution if API services are disabled, turn that on. If that doesn't work then I have my own leaderboard that saves and is much smaller. Feel free to use it

01local datastore = game:GetService("DataStoreService")
02local ds1 = datastore:GetDataStore("CashSaveSystem")
03 
04game.Players.PlayerAdded:connect(function(plr)
05    local folder = Instance.new("Folder", plr)
06    folder.Name = "leaderstats"
07    local cash = Instance.new("IntValue", folder)
08    cash.Name = "Money"
09 
10    cash.Value = ds1:GetAsync(plr.UserId) or 500 --You can replace 500 with how much you want the starting money to be at
11    ds1:SetAsync(plr.UserId, cash.Value)
12 
13    cash.Changed:connect(function()
14        ds1:SetAsync(plr.UserId, cash.Value)
15    end)
16end)
Ad
Log in to vote
1
Answered by
imKirda 4491 Moderation Voter Community Moderator
4 years ago

I see you are doing this:

1local Success, errormessage pcall(function()

But where is =?

Try this:

1local Success, errormessage = pcall(function()

There also could be some stuff about it in the output, this is where you should look for issues.

0
it just printing the errormessage in the out put Xx0966xX 41 — 4y
0
what does the error message say? imKirda 4491 — 4y

Answer this question