I have 2 folders in the datastore, one called abilities, and one called leaderstats. However, they keep replicating. Does anyone know why?
my player added script
local userId = player.userId
local key = "Player_" .. userId
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
local abilities = Instance.new("Folder")
abilities.Name = "Abilities"
abilities.Parent = player
local cash = Instance.new("IntValue")
cash.Name = "cash"
local success, ret = 1, 1
repeat
waitForRequestBudget(Enum.DataStoreRequestType.GetAsync)
local success, ret = pcall(datastore.GetAsync, datastore, key)
print("trying")
until success or not Players:FindFirstChild(player.Name)
if success then
cash.Value = ret or 0
cash.Parent = leaderstats
leaderstats.Parent = player
else
print("There was an error! " .. ret)
end
Because the repeat is always trying it, the function is checking whether we have enough budget for that. 2. it’s a function, but i have a PlayerAdded:Connect(playerAdded)
I noticed that you parent the cash and leaderstat Instance after the loop is completed(otherwise when not Players:FindFirstChild(player.Name)) meaning it parents to a player instance thats been set to nil. Is this done purposefully?