local DataStore = game:GetService("DataStoreService")
local killsds = DataStore:GetDataStore("Kills")
game.Players.PlayerAdded:connect(function(player)
local stats = Instance.new("Folder",player)
stats.Name = "Stats" -- creates a leaderboard
-- CREATES KILLS VALUE --
local killsvalue = Instance.new("NumberValue", stats)
killsvalue.Name = "Kills" -- creates a leaderstat value
killsvalue.Value = killsds:GetAsync(player.UserId) or 0 -- gets past value
killsds:SetAsync(player.UserId,killsvalue.Value) -- sets a new value
-- LEAVE BACKUP SAVE --
game.Players.PlayerRemoving:connect(function(player)
print("Saving Data for user "..player.UserId)
killsds:SetAsync(player.UserId,player.Stats.Kills.Value)
print(player.UserId.."'s Data has been saved successfully.")
if error then
print("DATA ERROR: "..player.UserId.."'s Data has been saved unsuccessfully")
end
end)
end)
I know you have to do something with a RemoteFunction but I'm not exactly sure what to do. Help is much appreciated.

6 comments
Can you specifically explain your problem?
The script works when FilteringEnabled is false, not when it's true. I converted my entire game other than this. I dont know what else you need to know.
Datastore only works in server scripts.
Thats what I'm using @cabbler
@SchonXIV, what exactly is/isn't working? Are there errors?
@chess123mate There's no errors, and the value doesn't save. The folder and value shows up.