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

My Data Script Isn't Saving, How Come?

Asked by
ImfaoXD 158
8 years ago

I made a brick that have image on it and when I touch the brick that has the image on it, the image in the GUI will appear when I touched the brick. But there is a problem, when I reset, the image from my GUI were all gone and also didn't save. I'm trying to figured it out how to make it work, but I can't. Could somebody help me?

If you don't know what I'm talking about, you can check out the link below to model that I made.

Link: http://www.roblox.com/D-item?id=313528352

local function setupPlayerData(player)
sessionData[player.PlayerGui.StickerGui.Stickers] = {1 = "imgsrc", 2= "imgsrc, 3="imgsrc, 4="imgsrc", 5 = "imgsrc", 6 = "imgsrc", 7 = "imgsrc", 8 = "imgsrc", 9 = "imgsrc", 10 = "imgsrc"} -- this can hold 10 stickers, up if more.
end
-- Require ModuleScript so we can change player stats
local PlayerStatManager = require(game.ServerStorage.PlayerStatManager)

-- After player joins we'll periodically give the player money and experience
game.Players.PlayerAdded:connect(function(player)
    while wait(2) do
        PlayerStatManager:ChangeStat(player, 'Money', 5)
        PlayerStatManager:ChangeStat(player, 'Experience', 1)
    end
end)
local DataStoreService = game:GetService('DataStoreService')
local playerData = DataStoreService:GetDataStore('PlayerData')

local function setupPlayerData(player)
    local data = playerData:GetAsync(player.UserId)
    if not data then
        data = {1 = "imgsrc", 2= "imgsrc, 3="imgsrc, 4="imgsrc", 5 = "imgsrc", 6 = "imgsrc", 7 = "imgsrc", 8 = "imgsrc", 9 = "imgsrc", 10 = "imgsrc"}
        playerData:SetAsync(player.UserId, sessionData[player])
    end
    sessionData[player] = data
end

game.Players.PlayerRemoving:connect(savePlayerData)

Answer this question