Issues With ProfileService

I’ve recently installed ProfileService for my game because I don’t have that much time before I have to publish it and I need a DataStore. I set up everything properly using the tutorial but it just doesn’t work.

Here’s what’s in “Template”:

local module = {
	Data = {Coins = 0,
		Gems = 0,

		Level = 0,
		Exp = 0,

		QuestNum = 1,
		QuestInProgress = false,
		QuestStats = {
			MetPete = false,
			SticksCollected = 0,
			BoughtWire = false,
		},

		Boosts = {
			CoinsBoosts = 0,
			CoinsBoostsTime = 0,
			GemsBoosts = 0,
			GemsBoostsTime = 0,
		},

		Settings = {
			Music = true,
			SFX = true,
			World = true,
			Notifications = true,
			ShowBoosts = true,
			ShowLevel = true,
			LevelDisplay = "Round",
			ShowTime = true,
			TimeFormat = "24H",
			Weather = true,
			RealisticLighting = true,
			FancyTerrain = true,
		},

		Items = {
			FishingWire = 0,
			WateringCan = 0,
			Fertilizer = 0,
			Trails = {
				RedTrail = 0,
				OrangeTrail = 0,
				YellowTrail = 0,
				LimeTrail = 0,
				GreenTrail = 0,
				CyanTrail = 0,
				BlueTrail = 0,
				PinkTrail = 0,
				PurpleTrail = 0,
				BlueFadeTrail = 0,
			},
		},

		Updates = {
			Tutorial = true,
			BETA = false,
		},

		Codes = {
			Code1 = false,
			Code2 = false,
			Code3 = false,
		},
	}
}

return module

Here’s what’s in “Data”, the script that should make it work:

local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")

local Template = require(script.Parent.Template)
local ProfileService = require(script.Parent.ProfileService)
local Manager = require(script.Parent.Manager)

--Always keep string as "Data" to no wipe Player data!!!--

local ProfileStore = ProfileService.GetProfileStore("Data", Template)

local function GiveLeaderstats(player: Player)
	local Profile = Manager.Profiles[player]
	if not Profile then return end
	
	--Leaderstats--
	
	local leaderstats = Instance.new("Folder", player)
	leaderstats.Name = "leaderstats"

	local Level = Instance.new("NumberValue", leaderstats) 
	Level.Name = "Level" 
	Level.Value = Profile.Data.Level

	local Exp = Instance.new("NumberValue", leaderstats)
	Exp.Name = "Exp" 
	Exp.Value = Profile.Data.Exp

	local Coins = Instance.new("NumberValue", leaderstats)
	Coins.Name = "Coins" 
	Coins.Value = Profile.Data.Coins

	local Gems = Instance.new("NumberValue", leaderstats)
	Gems.Name = "Gems" 
	Gems.Value = Profile.Data.Gems
	
	--Quests--

	local QuestNum = Instance.new("NumberValue", player)
	QuestNum.Name = "QuestNum"
	QuestNum.Value = Profile.Data.QuestNum

	local QuestInProgress = Instance.new("BoolValue", player)
	QuestInProgress.Name = "QuestInProgress"
	QuestInProgress.Value = Profile.Data.QuestInProgress
	
	--Quest Stats--

	local QuestStats = Instance.new("Folder", player)
	QuestStats.Name = "QuestStats"
	
	local MetPete = Instance.new("BoolValue", QuestStats)
	MetPete.Name = "MetPete"
	MetPete.Value = Profile.Data.QuestStats.MetPete

	local SticksCollected = Instance.new("NumberValue", QuestStats)
	SticksCollected.Name = "SticksCollected"
	SticksCollected.Value = Profile.Data.QuestStats.SticksCollected

	local BoughtWire = Instance.new("BoolValue", QuestStats)
	BoughtWire.Name = "BoughtWire"
	BoughtWire.Value = Profile.Data.QuestStats.BoughtWire
	
	--Boosts--
	
	local Boosts = Instance.new("Folder", player)
	Boosts.Name = "Boosts"

	local CoinsBoosts = Instance.new("NumberValue", Boosts)
	CoinsBoosts.Name = "CoinsBoosts"
	CoinsBoosts.Value = Profile.Data.Boosts.CoinsBoosts

	local CoinsBoostTime = Instance.new("NumberValue")
	CoinsBoostTime.Name = "Time"
	CoinsBoostTime.Value = Profile.Data.Boosts.CoinsBoostsTime

	local GemsBoosts = Instance.new("NumberValue")
	GemsBoosts.Name = "GemsBoosts"
	GemsBoosts.Value = Profile.Data.Boosts.GemsBoosts

	local GemsBoostTime = Instance.new("NumberValue")
	GemsBoostTime.Name = "Time"
	GemsBoostTime.Value = Profile.Data.Boosts.GemsBoostsTime
	
	--Items--
	
	local Items = Instance.new("Folder", player)
	Items.Name = "Items" 

	local FishingWire = Instance.new("NumberValue", Items)
	FishingWire.Name = "FishingWire" 
	FishingWire.Value = Profile.Data.Items.FishingWire

	local WateringCan = Instance.new("NumberValue", Items)
	WateringCan.Name = "WateringCan" 
	WateringCan.Value = Profile.Data.Items.WateringCan

	local Fertilizer = Instance.new("NumberValue", Items)
	Fertilizer.Name = "Fertilizer" 
	Fertilizer.Value = Profile.Data.Items.Fertilizer

	local Trails = Instance.new("Folder", Items)
	Trails.Name = "Trails"

	local RedTrail = Instance.new("NumberValue", Trails)
	RedTrail.Name = "Red"
	RedTrail.Value = Profile.Data.Items.Trails.RedTrail

	local OrangeTrail = Instance.new("NumberValue", Trails)
	OrangeTrail.Name = "Orange"
	OrangeTrail.Value = Profile.Data.Items.Trails.OrangeTrail

	local YellowTrail = Instance.new("NumberValue", Trails)
	YellowTrail.Name = "Yellow"
	YellowTrail.Value = Profile.Data.Items.Trails.YellowTrail

	local LimeTrail = Instance.new("NumberValue", Trails)
	LimeTrail.Name = "Lime"
	LimeTrail.Value = Profile.Data.Items.Trails.LimeTrail

	local GreenTrail = Instance.new("NumberValue", Trails)
	GreenTrail.Name = "Green"
	GreenTrail.Value = Profile.Data.Items.Trails.GreenTrail

	local CyanTrail = Instance.new("NumberValue", Trails)
	CyanTrail.Name = "Cyan"
	CyanTrail.Value = Profile.Data.Items.Trails.CyanTrail

	local BlueTrail = Instance.new("NumberValue", Trails)
	BlueTrail.Name = "Blue"
	BlueTrail.Value = Profile.Data.Items.Trails.BlueTrail

	local PurpleTrail = Instance.new("NumberValue", Trails)
	PurpleTrail.Name = "Purple"
	PurpleTrail.Value = Profile.Data.Items.Trails.PurpleTrail

	local PinkTrail = Instance.new("NumberValue", Trails)
	PinkTrail.Name = "Pink"
	PinkTrail.Value = Profile.Data.Items.Trails.PinkTrail

	local BlueFadeTrail = Instance.new("NumberValue", Trails)
	BlueFadeTrail.Name = "BlueFade"
	BlueFadeTrail.Value = Profile.Data.Items.Trails.BlueFade
	
	--Updates--
	
	local Updates = Instance.new("Folder", player)
	Updates.Name = "Updates"

	local Tutorial = Instance.new("BoolValue", Updates)
	Tutorial.Name = "Tutorial"
	Tutorial.Value = Profile.Data.Updates.Tutorial

	local BETA = Instance.new("BoolValue", Updates)
	BETA.Name = "BETA"
	BETA.Value = Profile.Data.Updates.BETA
	
	--Codes--
	
	local Codes = Instance.new("Folder", player)
	Codes.Name = "Codes"

	local Code1 = Instance.new("BoolValue", Codes)
	Code1.Name = "Code1"
	Code1.Value = Profile.Data.Codes.Code1

	local Code2 = Instance.new("BoolValue", Codes)
	Code2.Name = "Code2"
	Code2.Value = Profile.Data.Codes.Code2

	local Code3 = Instance.new("BoolValue", Codes)
	Code3.Name = "Code3"
	Code3.Value = Profile.Data.Codes.Code3
end

local function PlayerAdded(player: Player)
	local Profile = ProfileStore:LoadProfileAsync("Player_"..player.UserId)
	if Profile == nil then
		player:Kick("Player data issue, please try again. If this issue persists, please contact a member of staff.")
		return
	end
	
	Profile:AddUserId(player.UserId)
	Profile:Reconcile()
	Profile:ListenToRelease(function()
		Manager.Profiles[player] = nil
		player:Kick("Player data issue, please try again. If this issue persists, please contact a member of staff.")
	end)
	
	if player:IsDescendantOf(Players) == true then
		Manager.Profiles[player] = Profile
		GiveLeaderstats(player)
	else
		Profile:Release()
	end
end

for _, player in Players:GetPlayers() do
	task.spawn(PlayerAdded, player)
end


Players.PlayerAdded:Connect(PlayerAdded)

Players.PlayerRemoving:Connect(function(player: Player)
	local Profile = Manager.Profiles[player]
	if not Profile then return end
	Profile:Release()
end)

game:BindToClose(function(player: Player)
	local Profile = Manager.Profiles[player]
	if not Profile then return end
	Profile:Release()
end)

Please help!

2 Likes

Are there any errors? Or is nothing happening at all?

1 Like

No errors, absolutely nothing and the data just won’t save.

Maybe you could check, if the script runs at all? Try putting a print() command here somewhere, to see if it will be in the output.

image

1 Like

It doesn’t print, what now? (chars)

if you have already tried putting a print() command on this spot, without any reactions in the output, then I am afraid that I can’t really help, because I can’t think of what could be the problem. If it does print, then I might have an idea for a fix. It really should print on this line, because that’s where the script should start running, the other stuff above this line are local functions etc.
image

If it won’t print then I am confused.

Unfortunately still nothing, I really need this to work soon for my game. Ugh.

Hello.

From first observation there’s a couple of things I’d do differently here.

First off, on the PlayerAdded function I’d try to ForceLoad by replacing this:

local Profile = ProfileStore:LoadProfileAsync("Player_"..player.UserId)

with this:

local Profile = PlayerStore:LoadProfileAsync("Player_".player.UserId, "ForceLoad")

Second, can you use the DataStore editor plugin to confirm that stats are indeed not being saved? Incase the code is somewhat working and the issue is loading.

DataStore editor costs $9.99 so I’m not buying that and adding “ForceLoad” did nothing.

Is there any other way to figure it out? I used datastores before and they half worked because it only let me save a certain amount of value at the same time and that didn’t even work all the time. ProfileService is my one hope and that doesn’t work either!