Hello my data is not saving. And Im not getting errors.
local datastoreservice = game:GetService("DataStoreService")
local data1 = datastoreservice:GetDataStore("data2")
local data2 = datastoreservice:GetDataStore("data3")
game.Players.PlayerAdded:Connect(function(Player)
-- Crush Points
-- Top Crush Points
local NonUsingItemsFolder = Instance.new("Folder")
NonUsingItemsFolder.Parent = Player
NonUsingItemsFolder.Name = "NonUsingItemsFolder"
local leaderstats = Instance.new("Folder")
leaderstats.Parent = Player
leaderstats.Name = "leaderstats"
local EnabledGive = Instance.new("BoolValue")
EnabledGive.Parent = Player
EnabledGive.Value = false
EnabledGive.Name = "EnabledGive"
local Crush_Points = Instance.new("IntValue",leaderstats)
Crush_Points.Name = "Crush Points"
Crush_Points.Value = data1:GetAsync(Player.UserId,Crush_Points) or 0
local Top_Points = Instance.new("IntValue",leaderstats)
Top_Points.Name = "Top Crush Points"
Top_Points.Value = data2:GetAsync(Player.UserId,Top_Points) or 0
Player.CharacterAdded:Connect(function(chr)
local Billboard = game.ReplicatedStorage.Billboard.BillboardGui:Clone()
Billboard.Parent = chr.Head
while true do
wait(0.1)
Billboard.TextLabel.Text = Player.leaderstats["Crush Points"].Value
end
end)
end)
while true do
wait(1)
for i,v in pairs(game.Players:GetChildren()) do
if v.EnabledGive.Value == true then
v.leaderstats["Crush Points"].Value += 1
if v.leaderstats["Top Crush Points"].Value <= v.leaderstats["Crush Points"].Value then
v.leaderstats["Top Crush Points"].Value = v.leaderstats["Crush Points"].Value
end
end
end
end
game.Players.PlayerRemoving:Connect(function(player)
data1:SetAsync(player.UserId,player.leaderstats["Crush Points"].Value)
data2:SetAsync(player.UserId,player.leaderstats["Top Crush Points"].Value)
end)
Please help.