Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

PlayerGui is not a valid member of Player?!?

Asked by 3 years ago
Edited 3 years ago

So, what I am trying to do is store data for the folder. Whenever a player is exiting the game, the script will save his/her Data Folder. This script is a Server script and is the Child of ServerScriptService. The script I have written is:

local ds = game:GetService("DataStoreService")
local PlayerAmianData = ds:GetDataStore("AmianData")

game.Players.PlayerRemoving:Connect(function(player)
    local Owned_Amians = player.PlayerGui.Owned_Amians --Error

    for tries = 1, 10, 1 do
        local success, errormessage = pcall(function()
            PlayerAmianData:UpdateAsync(player.UserID, Owned_Amians)
        end)
        if success then
            break
        else
            PlayerAmianData:SetAsync(player.Name.."_"..player.UserID, Owned_Amians)
            break
        end
    end
end)

In this script, the PlayerAmianData is the user data. I have written another function to set the data, but I need help with this first. I'm new to Datastores and this is the best I have written. Please try to help or tell me if there is a better way to datastore a folder. Thanks!!

0
When the player leaves the game/is removed, it removes the player instance Pupppy44 671 — 3y
0
lol raid6n 2196 — 3y
0
You also can't manipulate GUIs on a server script. Dovydas1118 1495 — 3y
0
Then how do I save a folder?? Shounak123 461 — 3y

Answer this question