Hello!
I've been working on a data store script, but when I changed my cash value and test played again, it didn't work. I've checked the script for errors, and there are none, it also didnt print anything in the output, I have API Services on, and still dosent work, even published it.
Here's script:
local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder", plr)
leaderstats.Name = "leaderstats"
local cash = Instance.new("IntValue", leaderstats)
cash.Name = "Points"
local playerUserId = "Player_"..plr.UserId
print(playerUserId)
--Loads data
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(playerUserId)
end)
if success then
--Set data equal to current cash
cash.Value = data
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local playerUserId = "Player_"..plr.UserId
print(playerUserId)
local data = plr.leaderstats.Points.Value
local success, errormessage = pcall(function()
myDataStore:SetAsync(playerUserId, data)
end)
if success then
print("Data saved")
else
print("Save error")
warn(errormessage)
end
end)

27 comments
Lemme try that really quick.
Erased the old Mydatastore and replaced it, and replaced the if statement too
Did it work?
Tried it. Didn't work, I changed the points value too
Are you trying this in studio?
Yes.
Try doing a live test, sometimes studio is buggy
Ya mean join in client, not studio?
Are you changing the points value from the client side or server side. Client side won't save.
I changed the value from the server side in studio
But did you meant try it in roblox client or studio?
Okay, try and do a live test
Roblox client
Ohh, I understand you now.
kkkkkk
Still didn't work in roblox client, didnt try it in studio. Maybe DataStoreService is down?
That'd be extremely bad for every roblox game, so I'm doubting that
I know, but then how does the script dosen't work? I checked for errors, but 1 red flag is nothing printed in output
Replace line 35 with this (Idk my gut is telling me something): myDataStore:SetAsync(playerUserId, plr.leaderstats.Points.Value)
Nothing.
Well ,if someone wants to give up right now, we can probably agree on a point that DataStoreService is down.
rip
Well, if you want to give up, well, thank you for trying.
Do you mind putting the full script and your exact method of trying it?
Alright, I first tested it with studio client, then tested it on roblox client, then nothing happened, I changed the points value by explorer in studio, then developer console in roblox client. Full script is below
How are you changing your cash value exactly?
Conclusion: Data stores don't work in studio, even if api services is on....