of     1   

trail39rulez
#141736365Sunday, July 27, 2014 4:33 PM GMT

Can someone explain how they work? I got a script for it, but maybe the Value of "stat" should be my value. [This isn't my script, I'm just trying to figure out Data stores for my "Gold" leadboard, it won't save between servers no mater how I edit it] game.Players.PlayerRemoving:connect(function(player) local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats") local statstorage = player:FindFirstChild("leaderstats"):GetChildren() for i = 1, #statstorage do datastore:SetAsync(statstorage[i].Name, statstorage[i].Value) print("saved data number "..i) end print("Stats successfully saved") end) --[[ Loadin' Dem Stats --]] game.Players.PlayerAdded:connect(function(player) local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats") player:WaitForChild("leaderstats") wait(1) local stats = player:FindFirstChild("leaderstats"):GetChildren() for i = 1, #stats do stats[i].Value = datastore:GetAsync(stats[i].Name) print("stat numba "..i.." has been found") end end)
warspyking
#141736648Sunday, July 27, 2014 4:38 PM GMT

trail39rulez
#141738042Sunday, July 27, 2014 4:56 PM GMT

@a=war, I don't understand how the scripts work, and where you insert them, I tried the wiki but there was to much details, I couldn't understand it
EchoingEndlessly
#141738512Sunday, July 27, 2014 5:02 PM GMT

This script doesn't work. I tried it.
CounterCrysis
#141741399Sunday, July 27, 2014 5:31 PM GMT

Actually, I just so happen to still have the script from when I started learning about DataStore myself. The following code is a leaderboard that saves a player's Gold using DataStore. This allows the information to read later without needing the player being checked to be online. This means you could enter the game and view the Gold for anyone who had ever played the game. CashStore = game:GetService("DataStoreService"):GetDataStore("DataStore")   function PlayerEntered(player)         repeat wait() until player.Character                 local stats = Instance.new("IntValue")         stats.Parent = player         stats.Name = "leaderstats"                 local cash = Instance.new("IntValue")         cash.Parent = stats         cash.Name = "Cash"                 if CashStore:GetAsync("Points_"..player.Name) ~= nil then                 cash.Value = CashStore:GetAsync("Points_"..player.Name)                          else                 cash.Value = 0         CashStore:SetAsync("Points_"..player.Name, Val)         end                 cash.Changed:connect(function(Val)                 CashStore:SetAsync("Points_"..player.Name, Val)         end) end   game.Players.PlayerAdded:connect(PlayerEntered)
CounterCrysis
#141741763Sunday, July 27, 2014 5:34 PM GMT

I suppose I could also shorten/compact it a bit as well. CashStore = game:GetService("DataStoreService"):GetDataStore("DataStore") function PlayerEntered(player)         repeat wait() until player.Character         stats = Instance.new("IntValue",player)         stats.Name = "leaderstats"         cash = Instance.new("IntValue",stats)         cash.Name = "Cash"         if CashStore:GetAsync("Points_"..player.Name) ~= nil then                 cash.Value = CashStore:GetAsync("Points_"..player.Name)         else                 cash.Value = 0         CashStore:SetAsync("Points_"..player.Name, Val)         end         cash.Changed:connect(function(Val)                 CashStore:SetAsync("Points_"..player.Name, Val)         end) end game.Players.PlayerAdded:connect(PlayerEntered)
BothAngles
#141741930Sunday, July 27, 2014 5:36 PM GMT

CashStore = game:GetService("DataStoreService"):GetDataStore("DataStore");Spawn(wait) function PIayerEntered(pIayer) repeat wait() untiI player.Character stats = Instance.new("IntValue",player) stats.Name = "Ieaderstats" cash = lnstance.new("IntValue",stats) cash.Name = "Cash" if CashStore:GetAsync("Points_"..player.Name) ~= niI then cash.Value = CashStore:GetAsync("Points_"..pIayer.Name) else cash.Value = 0 CashStore:SetAsync("Points_"..pIayer.Name, VaI) end cash.Changed:connect(function(Val) CashStore:SetAsync("Points_"..pIayer.Name, Val) end) end game.PIayers.PlayerAdded:connect(PlayerEntered)
CounterCrysis
#141742417Sunday, July 27, 2014 5:41 PM GMT

Could you not post useless replies? The code I gave works perfect.
EchoingEndlessly
#141742518Sunday, July 27, 2014 5:42 PM GMT

@Counter, it actually doesn't work at all.
CounterCrysis
#141742711Sunday, July 27, 2014 5:43 PM GMT

I'm guessing your trying to run it in "Solo" mode rather than "Play" mode. You can't access DataStore without being in a server.
EchoingEndlessly
#141742762Sunday, July 27, 2014 5:44 PM GMT

I'm not dumb. It doesn't work.
CounterCrysis
#141745016Sunday, July 27, 2014 6:08 PM GMT

Are you sure about that? I just setup a clean place to double check. http://www.roblox.com/Lua-place?id=52614695
trail39rulez
#141838935Monday, July 28, 2014 3:03 PM GMT

I don't understand why it's not working for my servers, it's getting quiet annoying
XMLinjecting
#141840450Monday, July 28, 2014 3:25 PM GMT

umg hi trail im karmavore
trail39rulez
#141840762Monday, July 28, 2014 3:30 PM GMT

Hey Karm, you looking for help to? Or are you here helping?
BothAngles
#141840786Monday, July 28, 2014 3:30 PM GMT

i love when newbies (counter) give bad advice
XMLinjecting
#141840879Monday, July 28, 2014 3:31 PM GMT

A little bit of both trail :3
trail39rulez
#141840983Monday, July 28, 2014 3:33 PM GMT

Can you help with this? qq I need data to transfer over, but it always has trouble
BothAngles
#141841088Monday, July 28, 2014 3:35 PM GMT

scripting isnt for everyone
trail39rulez
#141841337Monday, July 28, 2014 3:38 PM GMT

I agree @both I tried learning it, I only understood through the wiki, math values Through editing scripts I understand a bit of functions, but not how to create them
trail39rulez
#141842820Monday, July 28, 2014 4:00 PM GMT

Figured out the issue finally, I had another script blocking it from working :\
wish_z
#141843527Monday, July 28, 2014 4:09 PM GMT

Do not use the player's name, use their userId instead. It's better. If they change their name, they lose all the data.

    of     1