How to save a gui value using datastore??
Asked by
8 years ago Edited 8 years ago
I'm trying to make it so when a stat changes, it saves. It isn't s stupid leaderstat. It's a IntValue inside a Gui. This is what I have so far; it doesn't work at all. I'm new to datastore and personally think it's stupid. I was just trying to save the ki value but still added the stamina and attack for later.
There are no errors. The problem is that the Ki value won't save
03 | local DataStore = game:GetService( "DataStoreService" ):GetDataStore( 'SSJClickerSaves' ) |
05 | game.Players.PlayerAdded:connect( function (Player) |
06 | local PlayerId = 'id-' .. Player.userId |
07 | local Ki = Player.PlayerGui.Stats.StatsFrame.Ki:FindFirstChild( "KiVal" ) |
08 | local Attack = Player.PlayerGui.Stats.StatsFrame.Physical:FindFirstChild( "AttackVal" ) |
09 | local Stamina = Player.PlayerGui.Stats.StatsFrame.Stamina:FindFirstChild( "StamVal" ) |
11 | local Save = DataStore:GetAsync(PlayerId) |
15 | local SaveValues = { Ki.Value } |
16 | DataStore:SetAsync(PlayerId, SaveValues) |
20 | game.Players.PlayerRemoving:connect( function (Player) |
21 | local PlayerId = 'id-' .. Player.userId |
22 | local SaveTable = { Player.PlayerGui.Stats.StatsFrame.Ki.KiVal.Value } |
23 | DataStore:SetAsync(PlayerId, SaveTable) |
This is for a DBZ game I'm making. It's in the pre-est of pre alphas.