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

How can I save the value of my IntValue Instance too? I tried some things out they didn't worked

Asked by 5 years ago

Also how would I do that?I tried some things out but they didn't worked my script:

local PetsDS = game:GetService("DataStoreService"):GetDataStore("PetSave")

game.Players.PlayerAdded:Connect(function(Player)

local PetsFolder = Instance.new("Folder")

PetsFolder.Name = "Pets"

PetsFolder.Parent = Player

local key = Player.UserId

pcall(function()

local Pets = PetsDS:GetAsync(key)

if Pets then

for i,v in pairs (Pets) do

local Pet = Instance.new("IntValue")

Pet.Parent = PetsFolder

if Pet then

Pet.Name = v.Name

end

end

end

end)

end)

game.Players.PlayerRemoving:Connect(function(Player)

local key = Player.UserId

pcall(function()

local PetsToSave = {}

for i,v in pairs(Player.Pets:GetChildren()) do

if v then

table.insert(PetsToSave,v.Name)

end

end

PetsDS:SetAsync(key,PetsToSave)

end)

end)

How can I improve it that I can save too the value of it?

0
Wrap your code in a lua code block SteamG00B 1633 — 5y

Answer this question