I made a datastore script, but it won’t work; I’m searching for help.
Output:
Script:
local ds = game:GetService("DataStoreService"):GetDataStore("--val01")
game.Players.PlayerAdded:Connect(function(player)
local key = "vls-"..player.userId
local folder = Instance.new("Folder")
folder.Parent = player
folder.Name = "leaderstats"
local currency = Instance.new("NumberValue",folder)
currency.Name = "Warns"
currency.Value = 0
local save = ds:GetAsync(key)
if save then
currency.Value = save
end
currency.Changed:Connect(function()
ds:SetAsync(key,currency.Value)
end)
end)
I searched a solution, but the error continued.
P.D: I have api services on and I published the game
I entered the game on roblox (not studio), and it seems to work now .
anyways I don’t know why it did not work on studio, I’ll search on devforum because I’m curious
Thank you all for your replies and help :3 .
There are a couple reasons why you data store doesn’t work. 1 make sure the game is published and the Enable Studio Access for API Services is on and don’t save you data each time the value changes. That can mess your game. Either save it each time a player leave and auto save with 1 minute interval