I need help with a ProfileService feature

Hey, I’m making an Obby game but my issue is about this game’s moderation. I’m attempting to manipulate data from a different server of the victim. I have a command named “set wins” that allow you to pick a player and set his wins amount.

Although, when trying to set it from a different server, I load his profile from ProfileService and it kicks him from the game.

My goal is to set his wins amount from a different server than his, without kicking him from the game.

This is part of the code in ProfileDataHandler

local function PlayerAdded(plr)
	
	local profile = PPS:LoadProfileAsync('Player_' .. plr.UserId, 'ForceLoad')
	
	if profile ~= nil then
		
		profile:Reconcile()
		
		profile:ListenToRelease(function()
			
			ProfileData[plr] = nil
			plr:Kick('Your profile has been loaded in another server. Please rejoin.')
			
		end)
		
		if plr:IsDescendantOf(game.Players) then
			
			ProfileData[plr] = profile
			
			PlayerDataLoaded(plr)
			
		else
			
			profile:Release()
			
		end
		
	else
		
		plr:Kick('Unable to load saved data. Please rejoin.')
		
	end
	
end

game.Players.PlayerAdded:Connect(PlayerAdded)

This is part of the command’s code

-- args = {'set', 'wins', 'eduGode_br', '5'}
if args[2] == 'wins' then -- set wins
	if not args[3] then

		commandBarAvailable = true
		return 'Argument 3 missing'
		
	elseif not args[4] and not tonumber(args[4]) then

		commandBarAvailable = true
		return 'Argument 4 missing or needs to be a number'
		
	end
	
	local amount = tonumber(args[4])
	
	local userId
	local s, r = pcall(function()
		userId = game.Players:GetUserIdFromNameAsync(args[3])
	end)
	if not s then
		
		commandBarAvailable = true
		return `@{args[3]} not found or ERROR`
		
	end
	
	local success, instance = pcall(function()
		
		return TPS:GetPlayerPlaceInstanceAsync(userId)
		
	end)

	warn('success: ' .. tostring(success))
	warn('instance: ' .. tostring(instance))
	
	if success and instance then
		
		plr = game.Players:GetPlayerByUserId(userId)
		repeat wait() until ProfileData[plr]
		
		local profile = ProfileData[plr]
		
		profile.Data.Wins = amount
		orderedWins:SetAsync(userId, profile.Data.Wins)
		
		commandBarAvailable = true
		return '@' .. args[3] .. ' amount was set to: ' .. amount
		
	elseif (success and not instance) or not success then 
		
		local profileHistory = PPS:ProfileVersionQuery('Player_' .. userId, Enum.SortDirection.Descending)
		local profile = profileHistory:NextAsync()
		
		profile.Data.Wins = amount
		profile:OverwriteAsync()
		orderedWins:SetAsync(userId, profile.Data.Wins)
		
		profile:Release()

		commandBarAvailable = true
		return '@' .. args[3] .. ' amount was set to: ' .. amount
	end
	
end

https://madstudioroblox.github.io/ProfileService/api/#global-updates

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