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: Data store

Previous Thread :: Next Thread 
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
30 Oct 2017 04:08 PM
I'm a noob to data stores and this is not working, what did I do wrong.. the output doesn't give me an error and it doesn't even print what it's supposed to :PP


--Data store
local DataStoreService = game:GetService("DataStoreService")
local PlayerStats = DataStoreService:GetDataStore("PlayerStats")
local Key = player.userId
player:WaitForDataReady()
local stats = player.InfoStore:GetChildren()
pcall(function()
for i = 1,#stats do
print(stats[i].Name.." " ..stats[i].Value)
stats[i].Value = PlayerStats:GetAsync(Key)
end
end)
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
30 Oct 2017 04:40 PM
Bump
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
30 Oct 2017 04:59 PM
Cmon help a nub out
Report Abuse
dj7679 is not online. dj7679
Joined: 11 Jun 2013
Total Posts: 307
30 Oct 2017 05:10 PM
Feel your struggle bro.
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
30 Oct 2017 05:14 PM
why are you using waitfordataready it doesn't do anything
Report Abuse
Linxesis is online. Linxesis
Joined: 19 Aug 2014
Total Posts: 325
30 Oct 2017 05:35 PM
Put a print on every other line, figure out when the printing stops for example
print("Work1")
line1..
line2..
print("Work2")
line3...
line...4
print("Work3")


Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
30 Oct 2017 06:35 PM
Bump
Report Abuse
TobiasVerandus is not online. TobiasVerandus
Joined: 24 Jun 2017
Total Posts: 81
30 Oct 2017 06:38 PM
Listen to that dudes advice. Use print and see when it stops printing. They come back and ask.
Report Abuse
Linxesis is online. Linxesis
Joined: 19 Aug 2014
Total Posts: 325
30 Oct 2017 06:39 PM
^


Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
30 Oct 2017 06:46 PM
Okay I will do that. :-----)
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
30 Oct 2017 06:47 PM
It prints up until "work3" then stops

local Key = "player- "..player.userId
local DataStoreService = game:GetService("DataStoreService")
local PlayerStats = DataStoreService:GetDataStore("PlayerStats",Key)

local stats = player.InfoStore:GetChildren()
print("work1")
pcall(function()
print("work2")
for i = 1,#stats do
print("work3")
print(stats[i].Name.." " ..stats[i].Value)
print("work4")
stats[i].Value = PlayerStats:GetAsync(Key)
end
end)
Report Abuse
Linxesis is online. Linxesis
Joined: 19 Aug 2014
Total Posts: 325
30 Oct 2017 06:48 PM
wonderful also add this at the top of the script it will wait 5 sec before it closes, witch will give it time to save

Line of script:
game:BindToClose(function() wait(5) end)



Report Abuse
Linxesis is online. Linxesis
Joined: 19 Aug 2014
Total Posts: 325
30 Oct 2017 06:50 PM
does print3 works or not??


Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
30 Oct 2017 06:52 PM
It prints up until "work3" then stops
Report Abuse
Linxesis is online. Linxesis
Joined: 19 Aug 2014
Total Posts: 325
30 Oct 2017 06:54 PM
yes or no it prints..


Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
30 Oct 2017 06:56 PM
Yes.. don't be mean.. >:O
Report Abuse
Linxesis is online. Linxesis
Joined: 19 Aug 2014
Total Posts: 325
30 Oct 2017 07:03 PM
print the #stats, they may not be anything

write before the print(for[i]...)
print(#stast[1])


Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
30 Oct 2017 07:14 PM
I printed #stats and it worked. Output printed "22". So why is it not printing the names and values?
Report Abuse
K7Q is not online. K7Q
Joined: 23 Mar 2013
Total Posts: 5546
30 Oct 2017 07:14 PM
instead of :

for i = 1,#stats do


try:


for i = 1,#stats, 1 do


it saved me once for negative numbers
Report Abuse
Linxesis is online. Linxesis
Joined: 19 Aug 2014
Total Posts: 325
30 Oct 2017 07:17 PM
sometimes for i,v in pairs() do
and for i,#whatever do will not do anything if the table is only nil values. I learned this the had way in my game when i was making my own matchmaking


Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
30 Oct 2017 07:26 PM
stats[i].Value = PlayerStats:GetAsync(Key)


bad argument #3 to 'Value' (string expected, got nil)
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
30 Oct 2017 07:29 PM
Oh well time for more tutorials
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
30 Oct 2017 08:24 PM
OK here is an UPDATED version of the script but it's STILL not saving. D:


local Key = "player- "..player.userId
local DataStoreService = game:GetService("DataStoreService")
local PlayerStats = DataStoreService:GetDataStore("PlayerStats")


FirstTime = Instance.new("BoolValue",InfoStore)
FirstTime.Name = "FirstTime"
FirstTime.Value = PlayerStats:GetAsync(Key) or true
PlayerStats:SetAsync(Key, player.InfoStore.FirstTime.Value)

player.InfoStore.FirstTime.Changed:connect(function()
PlayerStats:SetAsync(Key,player.InfoStore.FirstTime.Value)
end)
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
30 Oct 2017 08:40 PM
PLEASE I'M SLEEPY
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