Hey, i have problem with DataStore. I think it should works fine, but it says always "no data found"..
Here is script:
local DataStore = game:GetService("DataStoreService"):GetDataStore("CashStore") game.Players.PlayerAdded:connect(function(player) if script.Parent.SettingsTab.CashSave.Value == true then pcall(function() local store = DataStore:GetAsync("u_"..player.userId) if store then print("Found cash data") PlayerStats.Value = store else print ("No data found") end end) end end) game.Players.PlayerRemoving:connect(function(player) if script.Parent.SettingsTab.CashSave.Value == true then pcall(function() DataStore:SetAsync("u_"..PlayerStats.Value) print("Saved") end) end end)
It's not entire script, because script is long.
In line 20, you only specified the key, not the value. You need to provide the value for it to set as well!
local DataStore = game:GetService("DataStoreService"):GetDataStore("CashStore") game.Players.PlayerAdded:connect(function(player) if script.Parent.SettingsTab.CashSave.Value == true then pcall(function() local store = DataStore:GetAsync("u_"..player.UserId) -- Also, stop using deprecated stuff! It is a bad habit! if store then print("Found cash data") PlayerStats.Value = store else print ("No data found") end end) end end) game.Players.PlayerRemoving:connect(function(player) if script.Parent.SettingsTab.CashSave.Value == true then pcall(function() DataStore:SetAsync("u_"..player.UserId, PlayerStats.Value) -- There, this should work! print("Saved") end) end end)
Any questions? Please leave a comment below. Thanks!