Data store? Can I

Can I save values in playerGui from data store and ipairs?

1 Like

Yes, you can. But you should research data-stores beforehand!

2 Likes
Function Save(plr) 
DataStoring... 
For I, button in ipairs(plr.PlayerGuy:GetChildren()) 
For I, frame in ipairs(button:GetChildren())
For I, Int in ipairs(frame:GetChildren())
If Int:IsA("IntValue") then
...SetAsyns(PlrID, Int)
end
end
end
end
end) 

Function Load(plr) 
What I need to do here? 
DataStoring... 
For I, button in ipairs(plr.PlayerGuy:GetChildren()) 
For I, frame in ipairs(button:GetChildren())
For I, Int in ipairs(frame:GetChildren())
If Int:IsA("IntValue") then
...GetAsyns(PlrId, Int)
end
end
end
end
This? 
end)
1 Like

I write this but it dont work. Help pls

local Players = game.Players
local DataStoreService = game:GetService("DataStoreService")

local Info1 = DataStoreService:GetDataStore("Info1")
local Info2 = DataStoreService:GetDataStore("Info2")
local Info3 = DataStoreService:GetDataStore("Info3")

local function savePlayerData(plr)
	print("Save")
	for _, button in pairs(script.Parent:GetChildren()) do 
		if button:IsA("TextButton")  then
		print("Here script stopping. Helpppp")
			for _, frame in pairs(button:GetChildren()) do
				if frame:IsA("Frame") then
					local boughtLevels = frame:WaitForChild("boughtLevels")
					local BuyLvlPrice = frame:WaitForChild("BuyLvlPrice")
					local GiveMoneyReal = frame:WaitForChild("GiveMoneyReal")
					
					Info1:SetAsync(plr.UserId, boughtLevels.Value)
					Info2:SetAsync(plr.UserId,BuyLvlPrice.Value)
					Info3:SetAsync(plr.UserId,GiveMoneyReal.Value)
					print("Saved")
				end
			end
		end
	end
end

local function loadPlayerData(plr)
	print("Load")
	for _, button in pairs(script.Parent:GetChildren()) do 
		print("Load1")
		if button:IsA("TextButton")  then
		print("Here script stopping. Helpppp")
			for _, frame in pairs(button:GetChildren()) do
				print("Load2")
				if frame:IsA("Frame") then
					print("Load3")
					local boughtLevels = frame:WaitForChild("boughtLevels")
					local BuyLvlPrice = frame:WaitForChild("BuyLvlPrice")
					local GiveMoneyReal = frame:WaitForChild("GiveMoneyReal")

					boughtLevels.Value = Info1:GetAsync(plr.UserId) or 0
					BuyLvlPrice.Value = Info2:GetAsync(plr.UserId) or 0
					GiveMoneyReal.Value = Info3:GetAsync(plr.UserId) or 0
					print("Loaded")
				end
			end
		end
	end
end

I’m assuming that switching to ipairs() will fix your issue

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.