|
| 15 Aug 2016 08:40 PM |
Hey guys and gals! I wanting to save a variable for unlocking a mission in the game. I already have a script in the onplayeradd and playerleaving for strength and defense. However I don't want this variable to be shown as a leaderstat. All of the tutorials I've read show how to save a variable under leaderstat that shows on the leaderboard.
Is there a way to save a variable for each player that wouldn't be shown on the leaderboard? The easier the better :)
Example of what I use onPlayerAdded
local DataStore = game:GetService("DataStoreService"):GetDataStore("DaveStore")
game.Players.PlayerAdded:connect(function(player) stats = Instance.new("IntValue", player) stats.Name = "leaderstats" Strength = Instance.new("IntValue",stats) Strength.Name = "Strength" Defense = Instance.new("IntValue", stats) Defense.Name = "Defense" local key = "player-"..player.userId local savedValues = DataStore:GetAsync(key) if savedValues then --Save format: (Strength, Defense) Strength.Value = savedValues[1] Defense.Value = savedValues[2] else local valuesToSave = {Strength.Value, Defense.Value} DataStore:SetAsync(key, valuesToSave) end end)
What I use on playerLeaving
local DataStore = game:GetService("DataStoreService"):GetDataStore("DaveStore")
game.Players.PlayerRemoving:connect(function(player) local key = "player-"..player.userId --Save key: (Strength, Defense) local valuesToSave = {player.leaderstats.Strength.Value, player.leaderstats.Defense.Value} DataStore:SetAsync(key, valuesToSave) end) |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2016 08:46 PM |
| Well dont set your stats as child of leaderstats? like you can make another parent and set them to this one. Leaderstats is the thing that make your leaderboard because of a roblox thing idk. so if you set your stats as the child of something else then it not going to show on leaderboard cause the leaderboard aint recognizing them as their true children. |
|
|
| Report Abuse |
|
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
|
| 15 Aug 2016 08:55 PM |
| r u making a dbz game or naw |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2016 09:37 PM |
| That worked great ColonySimulater! Thanks for the advice! :D |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2016 09:37 PM |
| Yeah, its a dragon ball game |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 15 Aug 2016 10:23 PM |
https://forum.roblox.com/Forum/ShowPost.aspx?PostID=195621950
|
|
|
| Report Abuse |
|
|