my data for a game im working on isnt saving or not loading not sure. ive checked in studio and in the actual game and its not working
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 wheat = Instance.new("NumberValue")
wheat.Name = "Wheat"
wheat.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 wheatData, rebirthsData
local success, errormessage = pcall (function()
wheatData = DataStore:GetAsync("wheat-")..player.UserId
rebirthsData = DataStore:GetAsync("rebirths-")..player.UserId
end)
if success then
if wheatData then
wheat.Value = wheatData
rebirths.Value = rebirthsData
end
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
DataStore:SetAsync("wheat-"..player.UserId,player.leaderstats.Wheat.Value)
DataStore:SetAsync("rebirths-"..player.UserId,player.leaderstats.rebirths.Value)
end)
end)

2 comments
have you tried using prints to debug or looked at the output for errors?
Hey i edited the thing now u just can copy and paste the script into serverscriptservice