I see a problem here
you should have the value under the player so you can change the data on the server, making it a child of workspace forces you to do it locally if you have more then one player
this script is fine but the DataStoreService isn’t even used
I’ll give you an example
-- "player" variable doesn't exists here, just make one
local IntValue = player.leaderstats.IntValue -- get the IntValue
local DataStore = game:GetService("DataStoreService"): GetDataStore("Saver") -- get the DataStore
IntValue.Value = DataStore:GetAsync(player.Name) -- Set the IntValue's Value
IntValue:GetPropertyChangedSignal("Value"):Connect(function() -- I think you already know this, detects if the value was changed
if DataStore:GetAsync(player.Name) then -- checks if the saved value exists
DataStore:UpdateAsync(DataStore:GetAsync(player.Name), function() -- if exists, then update the saved value
return IntValue.Value -- save the value
end)
else -- if the saved value doesn't exists
DataStore:SetAsync(player.Name, IntValue.Value) -- just set it
end
Also, you have to access DataStores from server
if this won’t help you, then try to look in DevHub
no you should make a folder under the player on join and then create a value under the folder named your currency, a datastore would change the values if there was one
if you don’t want a leaderboard to show up then name the folder something other then “leaderstats”, if the folder is named literally anything else the leaderboard won’t show
Also just to add instead of saving values whenever they change you should save it every few minutes and save it when player is leaving and when the server is closing because if values change too quickly request queqe may fill and some requests may be dropped and data wont save
You should use the player’s User ID incase they change their name. The user id is the same forever, the name does not. If you use their name and they change it, all of their data is lost.