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

My datastore doesn't work and I did everything correctly? It suddenly stopped working.

Asked by 5 years ago
Edited by User#24403 5 years ago

My datastore doesn't work. I have done everything right. This is the script

```lua local Datastore = game:GetService("DataStoreService"):GetDataStore("pixel-DS3")

game.Players.PlayerAdded:Connect(function(player)

local Key = "Player-ID:" .. player.userId

local leaderstats = Instance.new("Folder", player)

leaderstats.Name = "leaderstats"

local Coins = Instance.new("NumberValue", leaderstats)

Coins.Name = "Coins"

Coins.Value = 0

local Strength = Instance.new("NumberValue", leaderstats)

Strength.Name = "Strength"

Strength.Value = 0

local Rebirths = Instance.new("NumberValue", leaderstats)

Rebirths.Name = "Rebirths"

Rebirths.Value = 1

-- GetAsync

local GetSave = Datastore:GetAsync(Key)

if GetSave then

Coins.Value = GetSave[1]

Strength.Value = GetSave[2]

Rebirths.Value = GetSave[3]

print("Data loaded for " .. player.Name)

else

local Numbers = {Coins.Value, Strength.Value, Rebirths.Value}

Datastore:SetAsync(Key, Numbers)

print("Data Saved for " .. player.Name)

end

end)

game.Players.PlayerRemoving:Connect(function(player)

local Key = "Player-ID:" .. player.userId

local ValuesToSave = {player.leaderstats.Coins.Value, player.leaderstats.Strength.Value, player.leaderstats.Rebirths.Value}

Datastore:SetAsync(Key, ValuesToSave)

print("Data Saved for " .. player.Name)

end) ```

0
If it was "right" it would work. Also Lua is not an acronym so it shouldn't be all in caps... User#24403 69 — 5y
0
You should use pcall() since DataStore fails sometimes. JakyeRU 637 — 5y
0
the site is having issues so its ----probably---- not gonna work, idk i dont work with datastore anyways LoganboyInCO 150 — 5y

1 answer

Log in to vote
0
Answered by
SpiralRBX 224 Moderation Voter
5 years ago
Edited by User#24403 5 years ago

Make the part where you get points Filtering Enabled.

What this means?

Well, FE is pretty simple once you get the hang of it. I will take you though the proper steps. So, the part you want to be FE is the time you get points. You need a RemoteEvent, a controlling script and the datastore script.

First, add a RemoteEvent into Replicated Storage. After this, rename it to whatever you want. I will name it Tutorial for now. Now add a script into ServerScriptService, and insert the following code.

game.ReplicatedStorage.Tutorial.OnServerEvent:Connect(function()
--Enter code to give money/cash/rebirth here!
end)

In between the function and the End, add the code that adds the currency. Now delete the part where it adds the currency in your original script that adds the currency, and change that code too:

game.ReplicatedStorage.Tutorial:FireServer()

--Spiral. Tell me if something doesn't work, or you don't understand!

0
Hope this helps! If it does, please mark this as answered! SpiralRBX 224 — 5y
0
Oh god, not an AlvinBlox video. DeceptiveCaster 3761 — 5y
0
Doesn't work GamingIntersectionYT -12 — 5y
Ad

Answer this question