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: DataStore, saving + loading a table.

Previous Thread :: Next Thread 
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
10 Jun 2015 01:49 PM
This aint on the wiki, so thats why I come before you.

I have a table.
I want the contents to save and load back into it when a player joins and saves when he / she exits(Can u save using the playerLeave event? Since he/she is gone, can i still save it that way?)
this is what i have so far, so u can work off of it.


Tab = {};

game.Players.PlayerAdded:connect(function(plr)\
local DataStore = game:GetService("DataStoreService"):GetDataStore("Tables");
for i,v in pairs(Tab) do
DataStore:UpdateAsync(key, function(old)
local new = old or {}--make a new table if theyre aint one
return new
end)
end
end)


Btw, I learned of DataStore yesterday, so pardon me not knowing what to do
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
10 Jun 2015 02:12 PM
hello?
Report Abuse
VineyardVine is not online. VineyardVine
Joined: 20 Nov 2010
Total Posts: 904
10 Jun 2015 02:17 PM
local datastore = game:GetService("DataStoreService"):GetDataStore("Kills")

game.Players.PlayerAdded:connet(function(player)
local kills = datastore:GetAsync(player.Name)
if kills == nil then
datastore:SetAsync(player.Name,0)
else
--Do whatchu want it here
end
end)

Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
10 Jun 2015 02:17 PM
That doesn't even have a table in it Vineyard. Lmao.
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
10 Jun 2015 02:24 PM
stop cussing, and plz fix his script?
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
10 Jun 2015 02:24 PM
I was going to help you, then you somehow got the idea that I've been cussing.

So no.
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
10 Jun 2015 02:26 PM
well alright, somene else?
Report Abuse
Tinfold is not online. Tinfold
Joined: 11 May 2010
Total Posts: 1435
10 Jun 2015 02:28 PM
You can't save a table directly. The only way you could save and load the table itself is by using the JSON functions.
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
10 Jun 2015 02:36 PM
please tell me how to do that
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
10 Jun 2015 03:39 PM
Well sorry for affending you, but i count "lmo" (with an a) as a cuss.
Please help!
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
10 Jun 2015 03:41 PM
laughing my ass off

is not the same as

you are an ass----
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
10 Jun 2015 03:43 PM
I think its gross still, but please just help.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
10 Jun 2015 03:44 PM
Lmfao. Get offended.

Use PlayerRemoving(Instance Player)
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
10 Jun 2015 04:00 PM
U are so evil. Get out.

I KNOW WHAT PLAYERREMOVING IS STUPID
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
10 Jun 2015 04:03 PM
You should have had a comma between 'is' and 'stupid' c:
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
10 Jun 2015 04:05 PM
u shud help me :c
Report Abuse
HalfCircuit is not online. HalfCircuit
Joined: 20 Apr 2011
Total Posts: 5018
10 Jun 2015 04:08 PM
a) You can save a table with DataStore
b) Your script is trying to iterate through nothing. Nothing is going to happen, and the loop will never run, because the table is nil.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
10 Jun 2015 04:08 PM
I did I told you what you should use. If you need more help, you can also use DataStore:SetAsync(string Key, var Data)
Report Abuse
HalfCircuit is not online. HalfCircuit
Joined: 20 Apr 2011
Total Posts: 5018
10 Jun 2015 04:42 PM
Hope this works..



local PlayerData = {Cash = 100; Level = 1;} --etc
local DataStore = game:GetService("DataStoreService"):GetDataStore("Tables");
game.Players.PlayerAdded:connect(function(plr)
local LoadedData = DataStore:GetAsync(plr.userId)
if LoadedData ~= nil then
for i,v in pairs(LoadedData) do
PlayerData[i] = LoadedData[v]
end
end
end)

game.Players.PlayerRemoving:connect(function(plr)
DataStore:SetAsync(plr.userId, PlayerData)
end)
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
11 Jun 2015 02:59 PM
i know why it doesent work, (it doesent)


U forgot to say if it is nil, which it always is the first time!


So...


if LoadedData == nil then
DataStore:SetAsync(plr.userId, PlayerData)
end
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