Hello, so I have this script and its not working. Like, its working, but if set, for example, 1 bee at my hive, and save the game, it just gonna load this not as 1, but as a whole hive, and i don't know how to fix, and also print shows it as it should, so there's only 1 bee. if someone understood me(because my explanation is really bad), please help! Here's my code:
local DataStoreService = game:GetService("DataStoreService") local DataStore = DataStoreService:GetDataStore("BeeGameData") local Cells = workspace:WaitForChild("Cells") local Hives = workspace:WaitForChild("Hives") function loadBees(player, parent, beesTable) print(unpack(beesTable)) if beesTable[1] ~= nil then for i, bee in pairs(beesTable) do local beeValue = Instance.new("IntValue") print(bee.Name, "-", bee.Slot) beeValue.Name = bee.Name beeValue.Value = bee.Slot beeValue.Parent = parent end for beeNum = 0, player.CoreStats.BeesAmount.Value do local beeID = Instance.new("IntValue") beeID.Name = beeNum beeID.Value = beeNum beeID.Parent = player.CoreStats.BeeIDs end else print("Player does not have bees") for i = 1, 25 do print(i) local beeValue = Instance.new("IntValue") beeValue.Name = "None" beeValue.Value = i beeValue.Parent = parent local beeID = Instance.new("IntValue") beeID.Name = i beeID.Value = i beeID.Parent = player.CoreStats.BeeIDs end end end game.Players.PlayerAdded:Connect(function(Player) local coreStats = Instance.new("Folder") coreStats.Name = "CoreStats" coreStats.Parent = Player local Honey = Instance.new("IntValue") Honey.Name = "Honey" Honey.Parent = coreStats local Pollen = Instance.new("IntValue") Pollen.Name = "Pollen" Pollen.Parent = coreStats local Claimed = Instance.new("StringValue") Claimed.Name = "HiveClaimed" Claimed.Parent = Player local Bees = Instance.new("Folder") Bees.Name = "Bees" Bees.Parent = coreStats local BeeIDs = Instance.new("Folder") BeeIDs.Name = "BeeIDs" BeeIDs.Parent = coreStats local BeesAmount = Instance.new("IntValue") BeesAmount.Name = "BeesAmount" BeesAmount.Parent = coreStats BeesAmount.Value = 25 local data = DataStore:GetAsync(Player.UserId) if data then Player.CoreStats.Honey.Value = data.Honey Player.CoreStats.Pollen.Value = data.Pollen Player.CoreStats.Capacity.Value = data.Capacity Player.CoreStats.BeesAmount.Value = data.BeesAmount loadBees(Player, Player.CoreStats.Bees, data.Bees) else loadBees(Player, Player.CoreStats.Bees, {}) end game:BindToClose(function() local saveData = {} saveData.Honey = Player.CoreStats.Honey.Value saveData.Pollen = Player.CoreStats.Pollen.Value saveData.Capacity = Player.CoreStats.Capacity.Value saveData.BeesAmount = Player.CoreStats.BeesAmount.Value saveData.Bees = {} if Player.HiveClaimed.Value ~= "" then print("yes hive") local playerCells = Cells:FindFirstChild(Player.HiveClaimed.Value) print(playerCells.Name) for _, cell in pairs(Player.CoreStats.Bees:GetChildren()) do local test = {Name = cell.Name, Slot = cell.Value} table.insert(saveData.Bees, {Name = cell.Name, Slot = cell.Value}) end else warn("Player bees wasn't saved, because player did not claimed the hive.") end print(unpack(saveData.Bees)) local succes, errormsg = pcall(function() DataStore:SetAsync(Player.UserId, saveData) end) if succes then print(Player.Name.."'s was successfully saved!") else warn("An error was occured, while saving data:",errormsg) end end) end)
Thanks!
LoadBees(Example1, Example2, Example3)
is never called in the script you showed us.