How can I change profile data without Player object (ProfileService)

I need help to change a player Data without player object using ProfileService Module!

I’ve tried so far this post, but without success

Whenever i try to change player data using just PlayerId i got this error and player get kicked from game when he tries to join again (after i change his data)

This is the code i was using to change player data without he’s in server

local function GetOfflineData(playerID, key)
	if typeof(playerID) == "string" then
		local sucesso = pcall(function()
			playerID = game:GetService("Players"):GetUserIdFromNameAsync(playerID)
		end)
		if not sucesso then
			warn("ERRO AO PEGAR ID DO JOGADOR", playerID)
			return
		end
	end
	local profile = ProfileStore:LoadProfileAsync("Player_" .. playerID)
	if not profile then return end
	if profile.Data[key] then
		--profile:Release()
		return profile.Data[key], profile
	end
end
				
if PlayerService:FindFirstChild(data) then --if player is in server just change normal way data
	local tlgnepa = PlayerService:FindFirstChild(data)
	local dgsfdfdfdaffa = NewHandlerData:Get(tlgnepa, "ValoresIniciais")
	dgsfdfdfdaffa["ClanName"] = "None"
	dgsfdfdfdaffa["ClanId"] = 0
	dgsfdfdfdaffa["EDONO"] = false
else --if player isn't in server try to change in offline mode
	game:GetService("ReplicatedStorage").Notify:FireClient(player, 'Jogador não está no server!')
	local tlgne, profile = NewHandlerData:GetOfflineData(data, "ValoresIniciais")
	tlgne["EDONO"] = false
	tlgne["ClanId"] = 0
	tlgne["ClanName"] = "None"
	profile:Release()
end

Any solutions will be appreciated, sorry for bad english!

1 Like