I am currently learning ProfileService, and I am not sure what some things mean. I searched them up in Google and in YouTube, but did not get much or got only unclear for me exaplanations.
I would appreciate if someone could explain to me what the following things mean and provide any examples if it is appropriate.
profile:Release()
profile:Reconcile()
profile:ListenToRelease
profile:AddUserId(player.UserId) -- I don't understand what is meant by "AddUserId" and why you have to add it if the "player" already has an ID and you can access it by indexing with a dot.
GiveLeaderstats()
Also, a more general question, but I saw it in one of the ProfileService tutorial videos. What is meant here by "player: Player? I usually see just one parameter there. Also, don’t know what the colon means in this case.
Removes the session lock for this profile for this Roblox server. Call this method after you’re done working with the Profile object. Profile data will be immediately saved for the last time.
Profile:Reconcile()
Fills in missing variables inside Profile.Data from profile_template table that was provided when calling ProfileService.GetProfileStore() . It’s often necessary to use :Reconcile() if you’re applying changes to your profile_template over the course of your game’s development after release.
Listener functions subscribed to Profile:ListenToRelease() will be called when the profile is released remotely (Being "ForceLoad" 'ed on a remote server) or locally (Profile:Release() ).
In common practice, the profile will rarely be released before the player leaves the game so it’s recommended to simply :Kick() the Player when this happens.
Profile:AddUserId(user_id)
-- user_id [number]
Associates a UserId with the profile. Multiple users can be associated with a single profile by calling this method for each individual UserId . The primary use of this method is to comply with GDPR (The right to erasure). More information in official documentation.
local function PlayerAdded(player: Player)
This is type checking, type checking is the process of verifying and enforcing constraints of types in values. You can add these to functions to show what value is expected to be passed.