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

Data Persistence + Loops?

Asked by 10 years ago

Hello. I really would like to know how to save something like this,

q = "HatList"
w = "HatDef"
e = "PosX"
r = "PosY"
t = "AmntHats"
y = "Down"

game.Players.PlayerAdded:connect(function(player)

     local HatDef = Instance.new("IntValue", player)
     HatDef.Name = "HatDefence"
     HatDef.Value = 1  
    local PosX = Instance.new("IntValue", player)
    PosX.Name = "PosX"
     PosX.Value = 10
local PosY = Instance.new("IntValue", player)
     PosY.Name = "PosY"
     PosY.Value = 10

local AmntHats = Instance.new("IntValue", player)
     AmntHats.Name = "HatAmnt"
     AmntHats.Value = 0

local Down = Instance.new("IntValue", player)
    Down.Name = "Down"
    Down.Value = 0

local HatList = Instance.new("StringValue", player)
HatList.Name = "HatList"
HatList.Value = ""

-- HOW DO I SAVE?

for i = 1,4 do
local ValueHat = Instance.new("IntValue", player)
    ValueHat.Name = i
    ValueHat.Value = 0
end

-- HOW DO I SAVE?

player:WaitForDataReady()

HatList.Value = player:LoadString(q)
HatDef.Value = player:LoadString(w)
PosX.Value = player:LoadString(e)
PosY.Value = player:LoadString(r)
AmntHats.Value = player:LoadString(t)
Down.Value = player:LoadString(y)




 end)

game.Players.PlayerRemoving:connect(function(player)
    player:SaveString(q,player.HatList.Value)
        player:SaveString(w,player.HatDefence.Value)
    player:SaveString(e,player.PosX.Value)
    player:SaveString(r,player.PosY.Value)
    player:SaveString(t,player.HatAmnt.Value)
    player:SaveString(y,player.Down.Value)

At the, HOW DO I SAVE, I want to know how to save the values from the loop. I just want a bit more efficiency. I'm sorry if you couldn't understand this. It was hard to explain.

0
somebody? drslicendice 27 — 10y

Answer this question