Well, first you have to use a unit of measurement. Got a little carried a way and made a little more than I planned to, but in short, this will keep all times the players play in a table constantly counting upwards PlayerTimes = nil - I think there's a better way to remove non-number indexes from tables but I dont know itĭataStore:UpdateAsync(theirkey,function(OldData) Add in all their other data blah blah blah OR you can load in their time and have it set instead of adding like im going to do in It wont be perfect since the server may lag, but here’s a sample of how your script would look local DataStoreService = game:GetService('DataStoreService')įor player,timeplayed in pairs (PlayersTimes) do You can keep a table in ServerScriptService that has a all the players by their index, and add them to the table. I believe you can create the UI through server to the player, but I’m not certain yet.The saving system above is not flawless, it can accidentally restart player’s data by mistake.Local success, errorMessage = pcall(secondsDS.SetAsync, timePlayed.Value, player.UserId) no time to break it down with UpdateAsync Players.PlayerRemoving:Connect(function(player) Local success, data = pcall(secondsDS.GetAsync, secondsDS, player.UserId) Local timePlayed = Instance.new("IntValue", stats) - exception here, "NumberValue" is alternative Local stats = Instance.new("Folder") - do not use second parameter for good reasons from PSA Players.PlayerAdded:Connect(function(player) Local secondsDS = DataStoreService:GetDataStore("SecondsDataStore") Local Players = game:GetService("Players") Local DataStoreService = game:GetService("DataStoreService") To fix this, add pcall with some error catching. Your saving and loading does not work well if the data stores decided to fail on the players.Loading and saving can be problematic if used incorrectly.YourUpdateUIButton.MouseButton1Click:Connect(function() Player.leaderstats:WaitForChild("TimePlayed").Changed:Connect(function() Local player = game:GetService("Players").LocalPlayer
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |