It prints Data loaded and Data Saved when entering or leaving the game, but it doesn't actually save. When I join the game it still says 0.
local Datastore = game:GetService("DataStoreService"):GetDataStore('Rocky-Test91')
game.Players.PlayerAdded:Connect(function(player)
local Key = 'Player-ID:' .. player.userId
local leaderstats = Instance.new("Folder")
leaderstats.Name = 'leaderstats'
leaderstats.Parent = player
local Pebbles = Instance.new("IntValue")
Pebbles.Name = 'Pebbles'
Pebbles.Value = 0
Pebbles.Parent = leaderstats
local GetSave = Datastore:GetAsync(Key)
if GetSave then
Pebbles.Value = GetSave
print('Data Loaded for '..player.Name)
else
local Numbers = {Pebbles.Value}
Datastore:SetAsync(Key, Numbers)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local Key = 'PlayerID:' .. player.userId
local ValueToSave = {player.leaderstats.Pebbles.Value}
Datastore:SetAsync(Key, ValueToSave)
print('Data Saved For '..player.Name)
end)

2 comments
Instead of "local Key = 'PlayerID:' .. player.userId" just do "local Key = player.userId"
That won't work. Datastores only accept strings as keys. One thing to note: It's "player.UserId" not "player.userId."