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

How Can I Make A Save Script That Save All Of My Data For My GUI?

Asked by
ImfaoXD 158
8 years ago

How can I make a script that save all of my stickers?

Here is a screen shot: http://prntscr.com/8sujlm

local DataStore = game:GetService("DataStoreService"):GetDataStore("StickersGui")

local connection = DataStore:OnUpdate("key", function(value)
    print("the key was changed to " .. value)
end)

DataStore:SetAsync("Stickers", 1)
DataStore:SetAsync("Stickers", 2)

connection:disconnect()

DataStore:SetAsync("Stickers", 3)

1 answer

Log in to vote
0
Answered by 8 years ago

Since I am not going to put all of the code directly in this reply because it would take a long time and it would consume a lot of space on my answer, you can and should take the "Setting Up Player Data" steps and do them. The link to this: http://wiki.roblox.com/index.php?title=Saving_Player_Data Once you have completed this, just be sure to change ( find it yourself ) these lines in which say

local function setupPlayerData(player)
    sessionData[player] = {Money = 0, Experience = 0}
end

change it to:

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

This may have to make you change some of your setup for your gui, but the script should work if completed correctly.

For the serverscriptservice script in which they have you include this:

-- 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)

change the line "PlayerStatManager:ChangeStat(player, 'Money', 5) to

player:WaitForChild("StickerGui").Stickers:FindFirstChild("1").Image = 'img src' --Assuming the first picture's name is 1 and you change img src to the images source and 1 is a ImageLabel

and remove the line "PlayerStatManager:ChangeStat(player, 'Experience', 1)

copy the line up ( not the playerstatmanager one but the player:WaitForChild() line and change 1 to 2, 2 to 3, etc.

Then use this

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)

This should work, and sorry I can not test it as I am both at school and do not have the GUI you are working on. You have to test it in a regular game, not in tool-->test-->play solo.

Sorry if this does not work, but is something I believe that may work if your GUI is set up correctly.

0
I can send you the model if you want me to. ImfaoXD 158 — 8y
0
Can you help me? I try but it doesn't work. Please, help me. Here is the model: http://www.roblox.com/Please-help-me-D-item?id=305474505 ImfaoXD 158 — 8y
Ad

Answer this question