Saving problem for gui texts

Hi guys I have a system that players can change the text of status label and interest label. my data saving isn’t working can anyone help?

ServerScriptService:
ProfileManager(Script)

-- Roblox DataStore-Service laden
local DataStoreService = game:GetService("DataStoreService")
local profileDataStore = DataStoreService:GetDataStore("PlayerProfiles") -- DataStore für Spielerprofile

-- Funktion: Spielerprofil laden
local function loadPlayerProfile(player)
	local playerKey = "Player_" .. player.UserId
	print("Lade Daten für Spieler:", player.Name)

	local success, profileData = pcall(function()
		return profileDataStore:GetAsync(playerKey)
	end)

	if success and profileData then
		print("Daten gefunden:", profileData.Status, profileData.Interests)
		player:SetAttribute("Status", profileData.Status)
		player:SetAttribute("Interests", profileData.Interests)
	else
		print("Keine Daten gefunden oder Fehler:", success)
		player:SetAttribute("Status", "Verfügbar")
		player:SetAttribute("Interests", "Keine angegeben")
	end
end

-- Funktion: Spielerprofil speichern
local function savePlayerProfile(player)
	local playerKey = "Player_" .. player.UserId
	local profileData = {
		Status = player:GetAttribute("Status") or "Verfügbar",
		Interests = player:GetAttribute("Interests") or "Keine angegeben"
	}
	print("Speichere Daten für Spieler:", player.Name, profileData)

	local success, errorMessage = pcall(function()
		profileDataStore:SetAsync(playerKey, profileData)
	end)

	if success then
		print("Daten erfolgreich gespeichert für:", player.Name)
	else
		warn("Fehler beim Speichern der Daten für " .. player.Name .. ": " .. errorMessage)
	end
end

-- Event: Wenn ein Spieler dem Spiel beitritt
game.Players.PlayerAdded:Connect(function(player)
	loadPlayerProfile(player)
end)

-- Event: Wenn ein Spieler das Spiel verlässt
game.Players.PlayerRemoving:Connect(function(player)
	savePlayerProfile(player)
end)

StarterGui->ProfileGui:
ProfileUIManager(LocalScript)

-- Verbindungen zu den UI-Elementen
-- Verbindungen zu den UI-Elementen
local player = game.Players.LocalPlayer
local profileFrame = script.Parent:WaitForChild("ProfileFrame")
local statusLabel = profileFrame:WaitForChild("StatusLabel")
local interestLabel = profileFrame:WaitForChild("InterestLabel")

-- Funktion: Profilanzeige aktualisieren
local function updateProfile()
	local status = player:GetAttribute("Status") or "Verfügbar"
	local interests = player:GetAttribute("Interests") or "Keine angegeben"

	statusLabel.Text = "Status: " .. status
	interestLabel.Text = "Interessen: " .. interests
end

-- Attribute-Änderungen überwachen
player:GetAttributeChangedSignal("Status"):Connect(updateProfile)
player:GetAttributeChangedSignal("Interests"):Connect(updateProfile)

-- Profil beim Spielstart anzeigen
updateProfile()

Make sure API Services is on, if it is and is not working, Try this:

local DataStoreService = game:GetService("DataStoreService")
local profileDataStore = DataStoreService:GetDataStore("PlayerProfiles") -- DataStore für Spielerprofile

local function loadPlayerProfile(player)
    local playerKey = "Player_" .. player.UserId
    print("Lade Daten für Spieler:", player.Name, "mit Schlüssel:", playerKey)

    local success, profileData = pcall(function()
        return profileDataStore:GetAsync(playerKey)
    end)

    if success and profileData then
        print("Daten gefunden:", profileData)
        player:SetAttribute("Status", profileData.Status or "Verfügbar")
        player:SetAttribute("Interests", profileData.Interests or "Keine angegeben")
    else
        print("Keine Daten gefunden oder Fehler:", success, profileData)
        player:SetAttribute("Status", "Verfügbar")
        player:SetAttribute("Interests", "Keine angegeben")
    end
end

local function savePlayerProfile(player)
    local playerKey = "Player_" .. player.UserId
    local profileData = {
        Status = player:GetAttribute("Status") or "Verfügbar",
        Interests = player:GetAttribute("Interests") or "Keine angegeben"
    }

    print("Speichere Daten für Spieler:", player.Name, "mit Schlüssel:", playerKey, profileData)

    local success, errorMessage = pcall(function()
        profileDataStore:UpdateAsync(playerKey, function(existingData)
            existingData = existingData or {}
            existingData.Status = profileData.Status
            existingData.Interests = profileData.Interests
            return existingData
        end)
    end)

    if success then
        print("Daten erfolgreich gespeichert für:", player.Name)
    else
        warn("Fehler beim Speichern der Daten für " .. player.Name .. ": " .. errorMessage)
    end
end

game.Players.PlayerAdded:Connect(function(player)
    loadPlayerProfile(player)
end)

game.Players.PlayerRemoving:Connect(function(player)
    savePlayerProfile(player)
end)

and print something on the pdate function to make sure that when a value changes, the function runs.

I tried it out but I don’t worked :frowning:

i don’t know what I can do now:(