|
| 12 Nov 2017 01:21 PM |
| Hello! I use BTS Leaderboard (Points, Survivals) and I don't know how to save it. When I rejoin my datas will loose. |
|
|
| Report Abuse |
|
|
KryptoKey
|
  |
| Joined: 10 Feb 2017 |
| Total Posts: 192 |
|
|
| 12 Nov 2017 01:22 PM |
http://wiki.roblox.com/index.php?title=SaveInstance
~ KryptoKey // Basic LUA |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2017 01:26 PM |
http://wiki.roblox.com/index.php?title=API:Class/DataStoreService
╴ “I seem to get mentioned alot in videogames.. i wonder why..” |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2017 02:10 PM |
| Kryptokey, I can't add the space of the intValue because I generate it from a Script. :/ |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2017 02:19 PM |
p = Instance.new("IntValue") p.Parent = player.Leaderstats P.Value = 20 p.Name = "gold"
you can get this value from going from
player.Leaderstats.gold.Value |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2017 03:23 PM |
| HILLBILLYY this not works, because I already write a code with points and survivals. BUT. I need to save survival's and point's data! How? |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2017 05:27 PM |
| Whatd your script that points/survivals? Why cant you save them they should still create a leaderstats value and put inside player |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2017 12:05 PM |
local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("PointsSaveSystem")
game.Players.PlayerAdded:connect(function(player) local leader = Instance.new("Folder",player) leader.Name = "leaderstats" local points = Instance.new("IntValue",leader) points.Name = "Points" points.Value = ds:GetAsync(player.UserId) or 0 ds:SetAsync(player.UserId, points.Value) points.Changed:connect(function() ds:SetAsync(player.UserId, points.Value) end) end)
game.Players.PlayerRemoving:connect(function(player) ds:SetAsync(player.UserId, player.leaderstats.points.Value) end) |
|
|
| Report Abuse |
|
|
K7Q
|
  |
| Joined: 23 Mar 2013 |
| Total Posts: 5546 |
|
|
| 17 Nov 2017 12:23 PM |
| ignore cryptokey, he is trying to misdirect you. use datastores instead. |
|
|
| Report Abuse |
|
|
Yokohane
|
  |
| Joined: 17 Oct 2016 |
| Total Posts: 61 |
|
|
| 17 Nov 2017 12:33 PM |
K ill help first make a script in workspace and name it "leaderboard" paste this script in:
local DataStore = game:GetService("DataStoreService"):GetDataStore("leaderboard")
game.Players.PlayerAdded:connect(function(Player)
local Folder = Instance.new('Folder', Player) Folder.Name = 'leaderstats' local Points = Instance.new('IntValue', Folder) Points.Name = 'Points' Points.Value = 0 local Survivals = Instance.new('IntValue', Folder) Survivals.Name = 'Survivals' Survivals.Value = 0 -- Data saving code goes here local key = "player-"..Player.userId local savedValues = DataStore:GetAsync(key) if savedValues then -- Save format: {Points,Survivals} Points.Value = savedValues[1] Survivals.Value = savedValues[2] else local valuesToSave = {Points.Value,Survivals.Value} DataStore:SetAsync(key, valuesToSave) end end)
NOT DONE YET!!! after that make ANOTHER SCRIPT IN WORKSPACE(YOU CANT HAVE THE SCRIPTS TOGETHER!!!)and name it "PlayerLeaving" after that paste this script in the NEW script("PlayerLeaving" Script that you just created):
local DataStore = game:GetService("DataStoreService"):GetDataStore("leaderboard")
game.Players.PlayerRemoving:connect(function(player) local key = "player-"..player.userId -- Save key: {Points,Survivals} local valuesToSave ={player.leaderstats.Points.Value,player.leaderstats.Survivals.Value} DataStore:SetAsync(key, valuesToSave) DataStore:UpdateAsync(key, function(oldValue) return valuesToSave end) end)
now you can go ahead and try it out in the real game but first
TAKE NOTE: -I MIGHT HAVE SOME TYPO SO CHECK IT AFTER YOU PASTED THE SCRIPTS -THIS DATA SAVING SCRIPT DOESNT WORK IN ROBLOX STUDIO SO DONT COME HERE AND SAY IT DOESNT WORK IN STUDIO.IT ONLY WORKS IN REAL GAME!!!
ALRIGHT THERE YOU GO!ENJOY!
-YG |
|
|
| Report Abuse |
|
|
Yokohane
|
  |
| Joined: 17 Oct 2016 |
| Total Posts: 61 |
|
|
| 17 Nov 2017 12:35 PM |
Jeez almost music 2k words in my previous reply -_- Never talk that much before lol 😁😁😁
-YG |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2017 01:13 PM |
| Thank you guys for helping! |
|
|
| Report Abuse |
|
|
Yokohane
|
  |
| Joined: 17 Oct 2016 |
| Total Posts: 61 |
|
|
| 17 Nov 2017 02:19 PM |
k it works??if yes nice lol
-YG |
|
|
| Report Abuse |
|
|
|
| 19 Nov 2017 11:39 AM |
This is working! Thank you!! :D
- SteakFighter |
|
|
| Report Abuse |
|
|