DataStore doesn't even run

Hello, I tried making my first datastore script for my game and I hoped that it will work, but when I launch the game both in studio/in-game the script doesn’t even start to run. I have studio API Services enabled but for some reason it still doesn’t work. I wanted to test it but why the heck it doesn’t want to run. Please help. Thanks

Edit: I am also aware that it will break because I am pushing it over the datastore limits and it will get queued but I am not sure if you can give me some instructions to prevent it, but if you can then please say it, thanks.

Here is my script:

local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("ThisWillErrorDataStore")

	local leaderstats ="Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	local Fertilizer ="IntValue")
	Fertilizer.Name = "Fertilizer"
	Fertilizer.Parent = leaderstats
	Fertilizer.Value = 0
	local Food ="IntValue")
	Food.Name = "Food"
	Food.Parent = leaderstats
	Food.Value = 0
	local InfoFolder ="Folder", player)
	InfoFolder.Name = "InfoFolder"
	local ConvertAmount ="StringValue", InfoFolder)
	ConvertAmount.Name = "ConvertAmount"
	ConvertAmount.Value = "100"
	local ConvertRate ="StringValue", InfoFolder)
	ConvertRate.Name = "ConvertRate"
	ConvertRate.Value = "100%"
	local CriticalPower ="StringValue", InfoFolder)
	CriticalPower.Name = "CriticalPower"
	CriticalPower.Value = "100%"
	local CriticalChance ="StringValue", InfoFolder)
	CriticalChance.Name = "CriticalChance"
	CriticalChance.Value = "3%"
	local Luck ="StringValue", InfoFolder)
	Luck.Name = "Luck"
	Luck.Value = "0"
	local InstantConvert ="StringValue", InfoFolder)
	InstantConvert.Name = "InstantConvert"
	InstantConvert.Value = "100"
	local Defense ="StringValue", InfoFolder)
	Defense.Name = "Defense"
	Defense.Value = "0%"
	local Jump ="StringValue", InfoFolder)
	Jump.Name = "JumpPower"
	Jump.Value = "56"
	local Walkspeed ="StringValue", InfoFolder)
	Walkspeed.Name = "Walkspeed"
	Walkspeed.Value = "20"
	local AttackMultiplier ="StringValue", InfoFolder)
	AttackMultiplier.Name = "AttackMultiplier"
	AttackMultiplier.Value = "100%"
	local Capacity ="StringValue", InfoFolder)
	Capacity.Name= "Capacity"
	Capacity.Value = "0"
	local CapacityMultiplier ="StringValue", InfoFolder)
	CapacityMultiplier.Name = "CapacityMultiplier"
	CapacityMultiplier.Value = "100%"
	local playerUserId = "Player_"..player.UserId
	--Loading Data
	local data
	local success, errormessage = pcall(function()
		data = myDataStore:GetAsync(playerUserId)
	if success then
		if data then
			Fertilizer.Value = data.Fertilizer
			Food.Value = data.Food
			ConvertAmount.Value = data.ConvertAmount
			ConvertRate.Value = data.ConvertRate
			CriticalPower.Value = data.CriticalPower
			CriticalChance.Value = data.CriticalChance
			Luck.Value = data.Luck
			InstantConvert.Value = data.InstantConvert
			Defense.Value = data.Defense
			Walkspeed.Value = data.Walkspeed
			Jump.Value = data.Jump
			AttackMultiplier.Value = data.AttackMultiplier
			Capacity.Value = data.Capacity
			CapacityMultiplier.Value = data.CapacityMultiplier

	local playerUserId = "Player_"..player.UserId
	local data ={
		Food = player.leaderstats.Food;
		Fertilizer = player.leaderstats.Fertilizer;
		ConvertAmount = player.InfoFolder.ConvertAmount;
		ConvertRate = player.InfoFolder.ConvertRate;
		CriticalPower = player.InfoFolder.CriticalPower;
		CriticalChance = player.InfoFolder.CriticalChance;
		Luck = player.InfoFolder.Luck;
		InstantConvert = player.InfoFolder.InstantConvert;
		Defense = player.InfoFolder.Defense;
		Walkspeed = player.InfoFolder.Walkspeed;
		Jump = player.InfoFolder.Jump;
		AttackMultiplier = player.InfoFolder.AttackMultiplier;
		Capacity = player.InfoFolder.Capacity;
		CapacityMultiplier = player.InfoFolder.CapacityMultiplier;
	local success, errormessage = pcall(function()
		myDataStore:SetAsync(playerUserId, data)
	if success then
		print("Data Successfully saved!")
		print("Error Detected")
1 Like

Does the script make the leaderstats folder and values for the player when they join? If it does and no data loads in, then you probably don’t have any data saved for the player.

No, the script doesnt even get service and create the leaderstat folders

Is the script in ServerScriptService?

Yes it is, I wouldn’t put it in workspace.

Can you make it print something on the first line to make sure the script runs?

Yea sure, I’ll try once I am home.

You’re doing game.Player.PlayerAdded

you should do:


The service is Players not Player

1 Like

OH youre right… Thanks for helping