Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Avinblox datastore not working No error message?

So i had a other datastore in my game it was from the toolbox it did not seem to save then i followed a tutorial by avinblox but it doesnt seem to work if does not display a error message nor does it give me a success print! what did i do wrong?

local DataStoreService = game:GetService("DataStoreService")

local myDataStore = DataStoreService:GetDataStore("StoredData")

game.Players.PlayerAdded:Connect(function(player)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local hair = Instance.new("IntValue")
	hair.Name = "Hair" 
	hair.Parent = leaderstats
	
	local haircolor = Instance.new("IntValue")
	haircolor.Name = "HairColor" 
	haircolor.Parent = leaderstats
	
	local Skin = Instance.new("IntValue")
	Skin.Name = "SkinColor" 
	Skin.Parent = leaderstats
	
	local Pants = Instance.new("IntValue")
	Pants.Name = "Pants"
	Pants.Parent = leaderstats
	
	local Shirt = Instance.new("IntValue")
	Shirt.Name = "Shirt"
	Shirt.Parent = leaderstats
	
	local HairData
	local HairColorData
	local SkinData
	local PantsData
	local ShirtData
	local success , errormessage = pcall(function()
		HairData = myDataStore:GetAsync(player.UserId.."-Hair")
		HairColorData = myDataStore:GetAsync(player.UserId.."-HairColor")
		SkinData = myDataStore:GetAsync(player.UserId.."-SkinColor")
		PantsData = myDataStore:GetAsync(player.UserId.."-Pants")
		ShirtData = myDataStore:GetAsync(player.UserId.."-Shirt")
	end)
	if success then
		hair.Value = HairData
		haircolor.Value = HairColorData
		Skin.Value = SkinData
		Pants.Value = PantsData
		Shirt.Value = ShirtData
	else
		warn(errormessage)
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local success ,errormessage = pcall(function()
	myDataStore:SetAsync(player.UserId.."-Hair",player.leaderstats.Hair.Value)
	myDataStore:SetAsync(player.UserId.."-HairColor",player.leaderstats.HairColor.Value)
	myDataStore:SetAsync(player.UserId.."-SkinColor",player.leaderstats.SkinColor.Value)
	myDataStore:SetAsync(player.UserId.."-Pants",player.leaderstats.Pants.Value)
	myDataStore:SetAsync(player.UserId.."-Shirt",player.leaderstats.Shirt.Value)
	end)
	if success then 
		print("Data Saved")
	else
		warn(errormessage)
	end
end)

2 answers

I found the issue the datastore was being acces by a local script while filtering was enabeld i am making a remote event now!

I seen your latest comment. Why do you have your datastore in a localscript? that is not right.

This discussion is preserved as it was. New answers, comments, and votes are closed.