generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: SAVE

Previous Thread :: Next Thread 
SteakFighter is not online. SteakFighter
Joined: 29 Oct 2014
Total Posts: 19
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 is not online. 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
Camper0008 is not online. Camper0008
Joined: 07 Apr 2013
Total Posts: 2504
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
SteakFighter is not online. SteakFighter
Joined: 29 Oct 2014
Total Posts: 19
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
HILLBILLYY is not online. HILLBILLYY
Joined: 08 May 2010
Total Posts: 764
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
SteakFighter is not online. SteakFighter
Joined: 29 Oct 2014
Total Posts: 19
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
HILLBILLYY is not online. HILLBILLYY
Joined: 08 May 2010
Total Posts: 764
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
SteakFighter is not online. SteakFighter
Joined: 29 Oct 2014
Total Posts: 19
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 is not online. 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 is not online. 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 is not online. 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
SteakFighter is not online. SteakFighter
Joined: 29 Oct 2014
Total Posts: 19
17 Nov 2017 01:13 PM
Thank you guys for helping!
Report Abuse
Yokohane is not online. Yokohane
Joined: 17 Oct 2016
Total Posts: 61
17 Nov 2017 02:19 PM
k it works??if yes nice lol


-YG
Report Abuse
SteakFighter is not online. SteakFighter
Joined: 29 Oct 2014
Total Posts: 19
19 Nov 2017 11:39 AM
This is working! Thank you!! :D

- SteakFighter
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image