I have absolutely no idea what I did. I literally just typed like 3 random words and it works now lol
Here is the working script back
local DataStoreService = game:GetService("DataStoreService")
local PartsStore = DataStoreService:GetDataStore("PlayerParts")
game:GetService("Players").PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local PartColor = Instance.new("Color3Value", leaderstats)
PartColor.Name = "Color"
PartColor.Value = Color3.new(255,255,255)
local Parts = Instance.new("IntValue", leaderstats)
Parts.Name = "Parts"
local data
local success, errorMessage = pcall(function()
data = PartsStore:GetAsync(player.UserId.."-Data")
end)
if success then
Parts.Value = data --What's not running.
print("Loaded data")
else
warn("Player's data wen't no")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errorMessage = pcall(function()
PartsStore:SetAsync(player.UserId.."-Data", player.leaderstats.Parts.Value)
end)
if success then
print("Data Saved")
else
warn("Data Fricked Up")
end
end)
function onShutDown()
task.wait(4)
end
game:BindToClose(onShutDown)
Did you change the value back? It was still saving, so it saved the original number. But if you joined again, it didn’t load and set it to 0, so upon leaving it saved as 0
local DataStoreService = game:GetService("DataStoreService")
local PartsStore = DataStoreService:GetDataStore("PlayerParts")
game:GetService("Players").PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local PartColor = Instance.new("Color3Value", leaderstats)
PartColor.Name = "Color"
PartColor.Value = Color3.new(255,255,255)
local Parts = Instance.new("IntValue", leaderstats)
Parts.Name = "Parts"
local success, errorMessage = pcall(function()
data = PartsStore:GetAsync(player.UserId.."-Data")
end)
if success then
Parts.Value = data[1]
else
print("Player's data wen't no")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errorMessage = pcall(function()
PartsStore:SetAsync(player.UserId.."-Data", {player.leaderstats.Parts.Value})
end)
if success then
print("Data Saved")
else
print("Data Fricked Up")
end
end)
function onShutDown()
task.wait(4)
end
game:BindToClose(onShutDown)
Do those scripts run locally? (I ask since I didn’t look at or touch any of the other scripts.) Because if they are, there is your main problem. The stat needs to be changed on the server else it won’t save.
If they aren’t running locally, I have no idea what your problem could be.
I recorded a video of it working for me, lemme trim it down and I’ll attach it in a couple minutes.
It’s completely fine, everyone makes silly mistakes like that at some point.
Funnily enough though, even before I did anything with the script it didn’t load (and I did change it on the server.) So, I did do something. Don’t really know what, but I did lol (I paid no attention to what I typed. I added random words and it worked)