Save your player data with ProfileService! (DataStore Module)

Profile:Save? What code are you using?

1 Like

Hey,

I’m pretty sure it says in the docs NOT to use it for ‘’‘profile.Data’’’

And the basic usage script from the docs

are you using profile:Release()?

1 Like

Yeah sure. Anyways, that’s how you save a profile, it will force a save and delay the next one.
Docs say that because that’s done automatically and you shouldn’t have to do that.

And for purchases (if that’s what you’re trying to do) you should look into MetaTags, though I still need to learn more about those. Anyhow there’s an usage example for developer product purchases here.

1 Like

Hey,

Yes I am.

(gdolmoldnmcodmc)

With the new memory service roblox released, could ProfileService benefit from it for profile locking so that the time to hop between places within a universe is quicker?

Use :ListenToHopReady() to improve server hopping times

3 Likes

Is there a way to have a definite amount of retries using ProfileStore:LoadProfileAsync()? So in case a specific amount of retries is done without successfully retrieving the profile, nil is being returned?

Is there a way to change data of a profile from a different server that its loaded in?

Lets say, player1 is in a full server, admin1 needs to change the “Banned” value of player1 from another server.

Is this possible to do? Or would you need to use MessagingService?

Presumably if you’re banning a player, it doesn’t matter if you steal the session lock from them if they’re online. They will be kicked since their session is no longer valid, and you can safely override the value and persist changes.

If you’re unbanning a player, they’re not able to access the game anyway, so session lock isn’t an issue.

For overriding other types of data, you should look into the global updates mechanism, as described in the official documentation.

If you want to ban them instantly, while still stealing their session lock to override the data, I would advise using MessagingService simultaneously.

I have a big problem but I don’t understand it. So whenever I test in studio and stop testing, studio freezes for around 10-20 seconds and then shows this error.
image
Here’s how I release the profile.

local function releaseProfile(player: Instance, storeKey: string)
	local success, result = pcall(function()
		local profileStore = Loaded_Profile_Stores[storeKey]
		local playerProfile = Loaded_Profiles[storeKey][player]
		if playerProfile then
            --return playerProfile.Data back to it's original state
			--playerProfile.Data = playerProfile.Data._state
			--ProfileServicePlus.ProfileRemoving:Fire(playerProfile, profileStore, player)
			playerProfile:Release()
		end
	end)

	return success, result
end

Is there any way to fix this? If there is, please reply as I need this for my ProfileService extension

@loleris I’m having a problem with ProfileService. Every time I hit play it kicks me out of the game. Why is this happening? Would this affect the players that joined the game? (I know it’s gonna kick when the profile isn’t loaded, but why isn’t it even loading in the first place?)

ProfileService does not do any kicking - the implementation you’re using does. Try to disable the lines that do the kicking and see what kind of conditions are leading to the lines that kick.

Just a wild guess, but if you’re trying something like storing all player data of a single game in one profile this is something you’d end up having with ProfileService.

ProfileService automatically releases profiles when a server is shutting down, so you shouldn’t bother manually connecting :Release() to :BindToClose().

If you’re editing the insides of ProfileService, then I can’t help you there either.

1 Like

I kick the player if the profile is nil. Why is it nil in the first place?

Edit: Also it warns me saying ProfileService doesn’t save dictionaries?

If you’re loading the profile properly, then the only way to get nil is to load the profile in two different places at the same time.

Am I loading the profile wrong, then? This code doesn’t seem wrong to me

local profile = ProfileStore:LoadProfileAsync("Player_" .. player.UserId, "ForceLoad")
	if profile then
		profile:ListenToRelease(function()
			Profiles[player] = nil
			player:Kick("Your profile has been loaded remotely. Please rejoin")
		end)
		if player:IsDescendantOf(Players) then
			Profiles[player] = profile
			PlayerDataLoaded(player)
		else
			profile:Release()
		end
	else
		print(profile)
	end

If you have this code repeated two times in the same game, one of the scripts will receive the profile as nil and perform the kick.

Thank you! However, I have one more question. Can we work with dictionaries in datastores? I put one to keep track of the skins owned by the player but I get a warning "[ProfileService]: DataStore API error [Store:“PlayerData”;Key:“Player_2400337484”] - “104: Cannot store Dictionary in data store. Data stores can only accept valid UTF-8 characters.”

It can store dictionaries, just not the dictionary you provided - see the troubleshooting page in the official documentation and you’ll sort this out.

2 Likes