My datastore doesnt save

hey! my datastore doesnt save some help me fix this problem thanks.
heres the script

local DataStoreService = game:GetService("DataStoreService")
local MyDataStore = DataStoreService:GetDataStore("PlayerData")

function module:DataStoreServiceSave(player,dataable)
	warn("Active the module function")
	local succes , err =pcall(function()
		MyDataStore:SetAsync(player.UserId,dataable)
		
		
	end)
	if succes then
		print("WARN")
	else
		error(err)
	end
		

heres the out putimage

1 Like

You literally made it so that when you call the function, this warning statement will be in the console.

hm … i deleted it and it still doesn’t work

game.Players.PlayerRemoving:Connect(function(plr)
	local SettingTable = {
		Fruit =	plr.Settings.Fruit.Value;


	}
	warn("The player left")
	local SettingTable = {
		Fruit =	plr.Settings.Fruit.Value;
		
		
	}
	DataSaver:DataStoreServiceSave(plr,SettingTable)

	
end)

heres my require script

What is the error? And show me the full scripts.

local DataSaver = require(script:WaitForChild("DataSaver"))
game.Players.PlayerAdded:Connect(function(plr)
	local Total = Instance.new("Folder")
	Total.Name  = "Settings"
	Total.Parent= plr
	local a = Instance.new("StringValue")
	a.Name  = "Fruit"
	a.Value = "None"
	a.Parent=Total
	local succes, data = DataSaver:DataStoreServiceLoad(plr)
	
	if succes then
		print(data.Fruit)
		warn("Succesfully load"..tostring(succes))
		a.Value = data.Fruit
		
	end
	
		
	
	
	end)


game.Players.PlayerRemoving:Connect(function(plr)
	local SettingTable = {
		Fruit =	plr.Settings.Fruit.Value;


	}
	warn("The player left")
	local SettingTable = {
		Fruit =	plr.Settings.Fruit.Value;
		
		
	}
	DataSaver:DataStoreServiceSave(plr,SettingTable)

	
end)

here !is caught no error

This might take a while. Please wait.

Make sure there’s spaces between the words and the =.

Use protective call to make sure your script doesn’t work after an unexpected error happening in DataStore.

local success, result = pcall(function()
    result = DataSaver:DataStoreServiceLoad(plr)
end)


if success then
    — use result to load data.
else
    — use result to print our error code.
end

This too as well, use pcalls.

1 Like