Please Check It could not save tower datas
local data = game:GetService("DataStoreService"):GetDataStore("TowerDataStore") function save(plr)
local saveData = {}
for i, v in pairs(plr:GetChildren())do
if v:IsA("StringValue") then
saveData[v.Name] = v.Value
end
end
data:SetAsync(plr.UserId, saveData)
end
game.Players.PlayerAdded:Connect(function(plr) for i = 1, 5 do local x = Instance.new("StringValue", plr) x.Name = "Tower"..tostring(i) x.Value = "Empty" end local getData local success, errorm = pcall(function() getData = data:GetAsync(plr.UserId) end) if success then if getData then for i, v in pairs(getData) do plr:FindFirstChild(i).Value = v end end end end)
game:BindToClose(function() for _, v in pairs(game.Players:GetChildren()) do wait(10) save(v) end end) game.Players.PlayerRemoving:Connect(function(plr) wait(10) save(plr) end)

1 comment
that didnt