So, i was following a tutorial by Alvin Blox (https://www.youtube.com/watch?v=tFATXcfL4zs&t=8s) and the saves don't seem to work. There are no errors it just doesn't work. Can I have some help?
(Stats Script)
local serverStorage = game:GetService("ServerStorage")
local DataStore = game:GetService("DataStoreService"):GetDataStore("PlayerSave")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local strength = Instance.new("NumberValue")
strength.Name = "Strength"
strength.Parent = leaderstats
local rebirths = Instance.new("IntValue")
rebirths.Name = "Rebirths"
rebirths.Parent = leaderstats
local dataFolder = Instance.new("Folder")
dataFolder.Name = player.Name
dataFolder.Parent = serverStorage.RemoteData
local debounce = Instance.new("BoolValue")
debounce.Name = "Debounce"
debounce.Parent = dataFolder
local strengthData, rebirthsData
local success,errormessage = pcall(function()
strengthData = DataStore:GetAsync("Strength-"..player.UserId)
rebirthsData = DataStore:GetAsync("Rebirths-"..player.UserId)
end)
if success then
if strengthData then
strength.Value = strengthData
rebirths.Value = rebirthsData
end
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
DataStore:SetAsync("Strength-"..player.UserID,player.leaderstats.Strength.Value)
DataStore:SetAsync("Rebirths-"..player.UserID,player.leaderstats.Rebirths.Value)
end)
end)
if there is other code that needs to be seen just tell me, thank you in advance.

2 comments
Thank you so much! That solved it right away!
Can you mark my answer as correct?