I’m essentially trying to create a saving inventory called “Relics”. When a player joins, it doesn’t create any values in the “Relics” folder. There is no error message.
Script:
local DataStoreService = game:GetService("DataStoreService")
local pointsStore = DataStoreService:GetOrderedDataStore("Points")
local minutesStore = DataStoreService:GetOrderedDataStore("Minutes")
local RelicsStore = DataStoreService:GetDataStore("Relics")
game.Players.PlayerAdded:Connect(function(Player)
local leaderstats = Instance.new("Folder", Player)
leaderstats.Name = "leaderstats"
local Relics = Instance.new("Folder", Player)
Relics.Name = "Relics"
local Points = Instance.new("IntValue", leaderstats)
Points.Name = "Points"
local MinutesPlayed = Instance.new("IntValue", leaderstats)
MinutesPlayed.Name = "Minutes Played"
local MaxScraps = Instance.new("IntValue", Player)
MaxScraps.Name = "MaxScraps"
MaxScraps.Value = 3
local Scraps = Instance.new("IntValue", Player)
Scraps.Name = "Scraps"
Scraps.Value = 0
local AccumulatedPoints = Instance.new("IntValue", Player)
AccumulatedPoints.Name = "AccumulatedPoints"
local AccumulatedMinutes = Instance.new("IntValue", Player)
AccumulatedMinutes.Name = "AccumulatedMinutes"
local AllPoints
local AllMinutes
local RelicInventory
local success, response = pcall(function()
AllPoints = pointsStore:GetAsync(Player.Name)
AllMinutes = minutesStore:GetAsync(Player.Name)
RelicInventory = RelicsStore:GetAsync(Player.UserId)
end)
AccumulatedPoints.Value = AllPoints or 0
AccumulatedMinutes.Value = AllMinutes or 0
if RelicInventory then
for i, v in pairs(RelicInventory) do
local Relic = Instance.new("ObjectValue", Relics)
Relic.Name = v
end
end
local OldPoints = Points.Value
local NewPoints
Points:GetPropertyChangedSignal("Value"):Connect(function()
NewPoints = Points.Value
local Difference = NewPoints - OldPoints
game.ReplicatedStorage.MoneyChanged:FireClient(Player, Difference)
OldPoints = NewPoints
end)
end)
game.Players.PlayerRemoving:Connect(function(Player)
pointsStore:SetAsync(Player.Name, Player.AccumulatedPoints.Value)
minutesStore:SetAsync(Player.Name, Player.AccumulatedMinutes.Value)
local RelicInventory = {}
for i, v in pairs(RelicInventory) do
table.insert(RelicInventory, v.Name)
end
RelicsStore:SetAsync(Player.UserId, RelicInventory)
end)