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: datastores are annoying

Previous Thread :: Next Thread 
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
08 Jul 2016 04:14 PM
i did all the steps
doesnt save between servers
tried using updateasnyc

but it failed


http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$448 (づ ゚ ³ ゚)づ
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
08 Jul 2016 04:20 PM
ur annoying


make sure the key and datastore have same names


My siggy is a lie
Report Abuse
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
08 Jul 2016 04:21 PM
they are

qq


http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$448 (づ ゚ ³ ゚)づ
Report Abuse
Adrian12094 is online. Adrian12094
Joined: 01 Feb 2014
Total Posts: 3172
08 Jul 2016 04:23 PM
Tbh data persistence was easier


#:lua
Report Abuse
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
08 Jul 2016 04:35 PM
qq


http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$448 (づ ゚ ³ ゚)づ
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
08 Jul 2016 04:51 PM
its working fine for me, post ur scripts big boi


My siggy is a lie
Report Abuse
GGGGG14 is not online. GGGGG14
Joined: 29 Jan 2012
Total Posts: 25344
08 Jul 2016 04:54 PM
post code.
Report Abuse
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
08 Jul 2016 04:56 PM
gimme a min


http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$448 (づ ゚ ³ ゚)づ
Report Abuse
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
08 Jul 2016 05:05 PM
my horrible code

local outfit1 = game:GetService("DataStoreService"):GetDataStore("Outfit1")
local outfit2 = game:GetService("DataStoreService"):GetDataStore("Outfit2")
local outfit3 = game:GetService("DataStoreService"):GetDataStore("Outfit3")




game.Players.PlayerAdded:connect(function(p)
local key = "player-"..p.userId

local cf = Instance.new("Folder",p)
cf.Name = "Customization"


local int = Instance.new("IntValue",cf)
int.Name = "Hair"

local int1 = Instance.new("IntValue",cf)
int1.Name = "Shirt"

local int2 = Instance.new("IntValue",cf)
int2.Name = "Pants"

local int3 = Instance.new("IntValue",cf)
int3.Name = "Accessory1"

local int4 = Instance.new("IntValue",cf)
int4.Name = "Accessory2"

local int5 = Instance.new("IntValue",cf)
int5.Name = "Accessory3"

local int6 = Instance.new("IntValue",cf)
int6.Name = "Accessory4"

local int7 = Instance.new("IntValue",cf)
int7.Name = "Accessory5"

local int8 = Instance.new("IntValue",cf)
int8.Name = "Hair2"

local int9 = Instance.new("IntValue",cf)
int9.Name = "Face"

local int10 = Instance.new("IntValue",cf)
int10.Name = "SkinColor"

local function GetOutfits()
local plrstats1 = outfit1:GetAsync(key)
local plrstats2 = outfit2:GetAsync(key)
local plrstats3 = outfit3:GetAsync(key)

if not plrstats1 then
local setnewval = {int.Value,int1.Value,int2.Value,int3.Value,int4.Value,int5.Value,int6.Value,int7.Value,int8.Value,int9.Value,int10.Value}
outfit1:SetAsync(key, setnewval)
print ('set '..p.Name .." outfit1")
-- else
-- print(p.Name .." Stats: " ..table.concat(plrstats1))
end

if not plrstats2 then
local setnewval = {int.Value,int1.Value,int2.Value,int3.Value,int4.Value,int5.Value,int6.Value,int7.Value,int8.Value,int9.Value,int10.Value}
outfit1:SetAsync(key, setnewval)
print ('set '..p.Name .." outfit2")
end

if not plrstats3 then
local setnewval = {int.Value,int1.Value,int2.Value,int3.Value,int4.Value,int5.Value,int6.Value,int7.Value,int8.Value,int9.Value,int10.Value}
outfit1:SetAsync(key, setnewval)
print ('set '..p.Name .." outfit3")
end
end

GetOutfits()--Checking if each datastore has data



end)

local event1 = Instance.new("RemoteEvent",game.ReplicatedStorage)--outfit1
event1.Name = "outfit1"
local event2 = Instance.new("RemoteEvent",game.ReplicatedStorage)
event2.Name = "outfit2"
local event3 = Instance.new("RemoteEvent",game.ReplicatedStorage)
event3.Name = "outfit3"


event1.OnServerEvent:connect(function(player,plr,data)
print 'fired'
local outfit1 = game:GetService("DataStoreService"):GetDataStore("Outfit1")
local key = "player-"..plr.userId
local plrstats = plr.Customization--Order in stats are saved {Hairs,Face,SkinColor,Shirt,Pants,Accessories1-5"}

local vals = {
plrstats.Hair,
plrstats.Hair2,
plrstats.Face,
plrstats.Shirt,
plrstats.Pants,
plrstats.SkinColor,
plrstats.Accessory1,
plrstats.Accessory2,
plrstats.Accessory3,
plrstats.Accessory4,
plrstats.Accessory5,
}

local valsToset = {}
for k,v in pairs(vals) do
valsToset[k] = v.Value
end

local saves = outfit1:GetAsync(key)

if data == "save" then
outfit1:SetAsync(key,valsToset)
print 'saved'
for i,v in pairs(valsToset) do
print(v)
end


elseif data == "load" then--looping the tables values with saved to load them in
print 'loading'
for i,v in pairs(vals) do
vals[i].Value = saves[i]
print(saves[i])
end
elseif data == "check" then
print 'checking'
for i,v in pairs(saves ) do
print(saves[i])
end
end
end)





http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$448 (づ ゚ ³ ゚)づ
Report Abuse
GGGGG14 is not online. GGGGG14
Joined: 29 Jan 2012
Total Posts: 25344
08 Jul 2016 05:06 PM
what is error?
Report Abuse
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
08 Jul 2016 05:06 PM
data doesnt go from server to server


http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$448 (づ ゚ ³ ゚)づ
Report Abuse
GGGGG14 is not online. GGGGG14
Joined: 29 Jan 2012
Total Posts: 25344
08 Jul 2016 05:10 PM
"Tried to use UpdateAsync"

Please only use update async if you're hoping to properly change values from server-to-server.

If the previous value of the key is important, use UpdateAsync. Using GetAsync to retrieve a value and then setting the key with SetAsync is dangerous because GetAsync sometimes returns cached data, and other game servers may have modified the key. Mind that there are limits that apply to this.

local DataStore = game:GetService("DataStoreService"):GetDataStore("Points")

game.Players.PlayerAdded:connect(function(player)
local key = "user_" .. player.userId
--we want to give 50 points to users each time they visit
DataStore:UpdateAsync(key, function(oldValue)
local newValue = oldValue or 0 --oldValue might be nil
newValue = newValue + 50
return newValue
end)
end)
Report Abuse
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
08 Jul 2016 05:14 PM
do i have to try updateasync again then

qq


http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$448 (づ ゚ ³ ゚)づ
Report Abuse
GGGGG14 is not online. GGGGG14
Joined: 29 Jan 2012
Total Posts: 25344
08 Jul 2016 05:15 PM
yes :c

I don't like messy datastores either, but good luck!
Report Abuse
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
08 Jul 2016 05:17 PM
thing is is that
the numebers getting set are going to be random doe


http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$448 (づ ゚ ³ ゚)づ
Report Abuse
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
08 Jul 2016 05:37 PM
i think i did it

event1.OnServerEvent:connect(function(player,plr,data)
print 'fired'
local outfit1 = game:GetService("DataStoreService"):GetDataStore("Outfit1")
local key = "player-"..plr.userId
local plrstats = plr.Customization--Order in stats are saved {Hairs,Face,SkinColor,Shirt,Pants,Accessories1-5"}

local vals = {
plrstats.Hair,
plrstats.Hair2,
plrstats.Face,
plrstats.Shirt,
plrstats.Pants,
plrstats.SkinColor,
plrstats.Accessory1,
plrstats.Accessory2,
plrstats.Accessory3,
plrstats.Accessory4,
plrstats.Accessory5,
}

local valsToset = {}
for k,v in pairs(vals) do
valsToset[k] = v.Value
end

local saves = outfit1:GetAsync(key)

if data == "save" then
outfit1:UpdateAsync(key,function(saves)
local newvals = vals
for i,v in pairs(newvals) do
saves[i] = newvals[i]
return newvals
end
end)
end


http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$448 (づ ゚ ³ ゚)づ
Report Abuse
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
09 Jul 2016 06:12 PM
still doesnt transfer

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa


http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$379 (づ ゚ ³ ゚)づ
Report Abuse
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
09 Jul 2016 08:51 PM
h


http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$12 (づ ゚ ³ ゚)づ
Report Abuse
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
09 Jul 2016 09:52 PM
criplling depression

if data == "save" then
outfit1:UpdateAsync(key,function(saves)
local newvals = valsToset
for i,v in pairs(newvals) do
saves[i] = newvals[i]
return newvals
end
end)
end


http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$292 (づ ゚ ³ ゚)づ
Report Abuse
icekiller8002 is not online. icekiller8002
Joined: 22 Jan 2013
Total Posts: 6636
09 Jul 2016 10:23 PM
just try a diff method besides datastores


the huge, nerdy game dev of OT | R$3,149 | the sad loner with no girlfriend | ヽ(ʘᴥʘ)ノ
Report Abuse
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
09 Jul 2016 10:26 PM
how am i suppose to save data then...?


http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$307 (づ ゚ ³ ゚)づ
Report Abuse
icekiller8002 is not online. icekiller8002
Joined: 22 Jan 2013
Total Posts: 6636
09 Jul 2016 10:26 PM
i use data persistance sometimes, it works


the huge, nerdy game dev of OT | R$3,149 | the sad loner with no girlfriend | ヽ(ʘᴥʘ)ノ
Report Abuse
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
09 Jul 2016 10:27 PM
not using dat e.e


http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$307 (づ ゚ ³ ゚)づ
Report Abuse
llaserx is not online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
09 Jul 2016 11:31 PM
wa esfzdfgtdnyfyhjn


http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$307 (づ ゚ ³ ゚)づ
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