How do I check when a value is updated using ProfileService?

I’m making an RPG project, and I have some labels that I want to make update (level, power points, ect).

But, I’m not sure how.

I have these 3 functions in my handler, as of now.

function Handler:Get(player, key)
	local profile = getProfile(player)
	assert(profile.Data[key], string.format("Data does not exist for: %s", key))
	
	return profile.Data[key]
end

function Handler:Set(player, key, value)
	local profile = getProfile(player)
	assert(profile.Data[key], string.format("Data does not exist for: %s", key))
	
	assert(type(profile.Data[key]) == type(value))
	
	profile.Data[key] = value
end

function Handler:Update(player, key, callback)
	local profile = getProfile(player)
	
	local oldData = self:Get(player, key)
	local newData = callback(oldData)
	
	self:Set(player, key, newData)
end

You would use Replica for this.

You’d use a BindableEvent or signal module on the same context.

For the client, you’d have to fire the data using a RemoteEvent every time the value changes, or something like Replica, as said above.

Does that mean I use Replica and ProfileService or just Replica?

(Sorry if im being dumb)

You would use both. ProfileStore (the newer version) is a datastore module while Replica is a state replication module.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.