I have followed tutorials and did everything they told me to do but the script won't work and there is nothing in the output. the only thing I changed is that there isn't a leaderstats folder but it just has a different name.
here is the script
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DataStore")
local GravelCo = DataStoreService:GetDataStore("GravelCo")
game.Players.PlayerAdded:Connect(function(player)
local Data = Instance.new("Folder")
Data.Name = "DataFolder"
Data.Parent = player
local GravelColor = Instance.new("IntValue")
GravelColor.Name = "GravelColor"
GravelColor.Parent = Data
local data
local success, error = pcall(function()
data = GravelCo:GetAsync(player.UserId.."-GravelColor")
end)
if success then
GravelColor.Value = data
else
warn(error)
print("error saving")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, error = pcall(function()
GravelCo:SetAsync(player.UserId.."-GravelColor",player.DataFolder.GravelColor.Value)
end)
if success then
print("data Saved")
else
print("error Saving")
warn(error)
end
end)

1 comment
try uploading the game and then playing it, they dont work in studio