Session Locking (I'm stuck)

I want to make session locking to fix a few trading duplication glitches found in my game. This is what I got so far:

local lock = {};
local dss = game:GetService("DataStoreService")
local locked = dss:GetDataStore('SessionLocked1.1')
game.Players.PlayerAdded:Connect(function(player)
	if not locked:GetAsync(player.UserId)  then
		locked:SetAsync(player.UserId, "Unlocked")		
	end
end)
lock.CreateSessionLock = function(player)
	if locked:GetAsync(player.UserId) ~= 'Unlocked' then
		print('Already sessioned locked!')
	else
		locked:SetAsync(player.UserId, game.GameId)
		lock.StartUnlockSection(player, game.GameId);
	end
end

return lock;

I’m not sure where to go next.

I’m not an expert at datastores but I believe you need to use MessagingService for this.

You can just use ProfileService which has session locking instead of reinventing the wheel.

1 Like

I don’t know how to use profile service and it’d be alot of work to switch my entire data module to it. I’d also have to wipe my game’s data.