so in my simulator game im doing the tutorial from alvin blox everything is working but the datastore wont save please help me:
local serverStorage = game:GetService("ServerStorage")
local datastore = game:GetService("DataStoreService"):GetDataStore("PlayerSave3")
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, rebirthdata
local success, errormessage = pcall(function()
strengthdata = datastore:GetAsync("strength-"..player.UserId)
rebirthdata = datastore:GetAsync("rebirths-"..player.UserId)
end)
if success then
if strengthdata then
strength.Value = strengthdata
rebirths.Value = rebirthdata
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)
