I get an error saying that wool is not part of leaderstats, but it actually is.
Here is my script causing the error.
local u1 = {"", 'K', "M", "B", "T", "Qa", "Qi", "Sx", "Sp", "Oc", "No", "Dc"}
function v1(p1)
for v2 = 1, #u1 do
if tonumber(p1) < 10 ^ (v2*3) then
return math.floor(p1/(10^((v2-1)*3)/100))/100 .. u1[v2]
end
end
end
local player = game.Players.LocalPlayer
while wait() do
script.Parent.TextLabel.Text = v1(player:WaitForChild("leaderstats").Wool.Value)
end
My leaderstats:
local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("MyDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
coins = Instance.new("NumberValue")
coins.Name = "Gold"
coins.Parent = leaderstats
if myDataStore:GetAsync(player.UserId..' - Gold') then
coins.Value = myDataStore:GetAsync(player.UserId..' - Gold')
else
coins.Value = 0
end
Eggs = Instance.new("NumberValue")
Eggs.Name = "Eggs"
Eggs.Parent = leaderstats
if myDataStore:GetAsync(player.UserId..' - Eggs') then
Eggs.Value = myDataStore:GetAsync(player.UserId..' - Eggs')
else
Eggs.Value = 0
end
Milks = Instance.new("NumberValue")
Milks.Name = "Milk"
Milks.Parent = leaderstats
if myDataStore:GetAsync(player.UserId..' - Milks') then
Milks.Value = myDataStore:GetAsync(player.UserId..' - Milks')
else
Milks.Value = 0
end
Wool = Instance.new("NumberValue")
Wool.Name = "Wool"
Wool.Parent = leaderstats
if myDataStore:GetAsync(player.UserId..' - Wool') then
Wool.Value = myDataStore:GetAsync(player.UserId..' - Wool')
else
Wool.Value = 0
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local s,e = pcall(function()
myDataStore:SetAsync(player.UserId..' - Gold',coins.Value)
end)
if e then
warn('Failed saving "Gold" for '..player.DisplayName)
end
local s,e = pcall(function()
myDataStore:SetAsync(player.UserId..' - Eggs',Eggs.Value)
end)
if e then
warn('Failed saving "Eggs" for '..player.DisplayName)
end
local s,e = pcall(function()
myDataStore:SetAsync(player.UserId..' - Milks',Milks.Value)
end)
if e then
warn('Failed saving "Milk" for '..player.DisplayName)
end
local s,e = pcall(function()
myDataStore:SetAsync(player.UserId..' - Wool',Wool.Value)
end)
if e then
warn('Failed saving "Wool" for '..player.DisplayName)
end
end)
game:BindToClose(function()
for i, player in pairs(game.Players:GetChildren()) do
player:Kick("Server Closed")
end
wait(2)
end)