I am writing a leaderstats script and I have the datastore but it won’t load for some reason.
I have a “Parts” = data.
Here is my script:
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 playerUserID = ("Player_" .. player.UserId)
local success, errorMessage = pcall(function()
data = PartsStore:GetAsync(playerUserID)
end)
if success then
Parts.Value = data --What's not running.
else
print("Player's data wen't no")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerUserID = ("Player_" .. player.UserId)
local data = player.leaderstats.Parts.Value
local success, errorMessage = pcall(function()
PartsStore:SetAsync(playerUserID, data)
end)
if success then
print("Data Saved")
else
print("Data Fricked Up")
end
end)
function onShutDown()
task.wait(4)
end
game:BindToClose(onShutDown)
I used a print and everything is running. It is saving the data, loading it, and printing the “Parts” value afterwards. I don’t know what’s wrong
I’m not seeing anything wrong, but I also didn’t fully read it. I only glanced, so I may have missed something.
Are you receiving any errors? If not, check to see if “Enable Studio Access to API Services” is enabled.
If you are not receiving errors and API access is enabled, tell me and I’ll do a deeper read. I just woke up, so I’m a little tired, which is why I didn’t the first time lol.
Yes API is enabled. I’m not seeing any error messages related to the script. It’s just showing it is running. Here is my output, mainly look at the bottom.
08:57:36.315 Requiring asset 512742721.
Callstack:
cloud_8428896693.archimedesTwo.initiatePlugin.MainModule, line 29
cloud_8428896693.archimedesTwo.initiatePlugin.MainModule, line 28
- Server
08:57:36.376 loadstring() is not available - Server
08:57:36.376 Stack Begin - Studio
08:57:36.376 Script 'cloud_183586902.Build v4.1.Plugin', Line 30 - function LoadResource - Studio
08:57:36.376 Script 'cloud_183586902.Build v4.1.Plugin', Line 32 - Studio
08:57:36.376 Stack End - Studio
08:57:36.395 Requiring asset 518094091.
Callstack:
cloud_8428896693.archimedesTwo.initiatePlugin.MainModule, line 30
cloud_8428896693.archimedesTwo.initiatePlugin.MainModule, line 28
- Server
08:57:37.201 loadstring() is not available - Client
08:57:37.202 Stack Begin - Studio
08:57:37.202 Script 'cloud_183586902.Build v4.1.Plugin', Line 30 - function LoadResource - Studio
08:57:37.202 Script 'cloud_183586902.Build v4.1.Plugin', Line 32 - Studio
08:57:37.202 Stack End - Studio
08:57:37.203 Player Data Loaded - Server - Stats:21
08:57:37.203 Parts == 0 - Server - Stats:23
08:57:39.963 Disconnect from ::ffff:127.0.0.1|53963 - Studio
08:57:40.143 Data Saved - Server
Have you tried increasing your stats on the server side (in studio, or optionally in game with the console?)
If you have not, try that. If you have, would you be comfortable with sharing the game file (like, saving the game as a file (if it already isn’t)) and then send it to me? If not, that’s perfectly fine and understandable, it just makes it much easier to help.
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] --What's not running.
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)