I want the data to be saved ever 6.5 seconds or when the player leaves and I am getting the prints so I know it is running but it is not actually saving the data.
local DataStore = game:GetService("DataStoreService")
local ds1 = DataStore:GetDataStore("TestData")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Model")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cash = Instance.new("IntValue")
cash.Name = "Cash"
cash.Value = 0
cash.Parent = leaderstats
local size = Instance.new("NumberValue")
size.Name = "Size"
size.Value = 1.07
size.Parent = leaderstats
ds1:SetAsync(player.UserId, cash.Value, size.Value)
--[[cash.Changed:Connect(function()
print("Saving Data")
ds1:SetAsync(player.UserId, cash.Value, size.Value)
print(player.UserId.."'s Data of "..cash.Value.." "..cash.Name.." has been saved!")
end)--]]
while true do
wait(6.5)
print("Saving Data")
ds1:SetAsync(player.UserId, cash.Value, size.Value)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
ds1:SetAsync(player.UserId, player.leaderstats.Cash.Value, player.leaderstats.Size.Value)
print(player.UserId.."'s Data of "..player.leaderstats.cash.Value.." "..player.leaderstats.cash.Name.." has been saved!")
end)

1 comment
It is still not saving but I am not getting any errors