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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: check datastore of player?

Previous Thread :: Next Thread 
Festivereinhard2 is not online. Festivereinhard2
Joined: 08 Dec 2015
Total Posts: 587
10 Jan 2017 07:35 AM
Hi, how do i make a script check the datastore of a player. for example in the datastore for a player there is a value which is 0. Then i want a script to check if that value is 0. To make the datastore for each player i used the code from the wiki tutorial, and i only got this far to make the script check. part is the brick that touches the parent of the script.

local key = "user_"..game.Players:GetPlayerFromCharacter(part.Parent).userId
DataStore:GetAsync(key, function()
end)
Report Abuse
Festivereinhard2 is not online. Festivereinhard2
Joined: 08 Dec 2015
Total Posts: 587
10 Jan 2017 07:47 AM
bump
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
10 Jan 2017 07:48 AM
GetAsync iirc only has one argument, which is the key.
so you'd say

local key = "user_"..game.Players:GetPlayerFromCharacter(part.Parent).userId
local data = DataStore:GetAsync(key)


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
10 Jan 2017 07:48 AM
2 minute bumps in the scripters subforum?

r u insane


Report Abuse
Festivereinhard2 is not online. Festivereinhard2
Joined: 08 Dec 2015
Total Posts: 587
10 Jan 2017 07:51 AM
alright, but how do i check for a value in the data store?
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
10 Jan 2017 07:51 AM
Well, what are you saying to that key in the first place?
An array?
One value?




Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
10 Jan 2017 07:52 AM
saving*


Report Abuse
Festivereinhard2 is not online. Festivereinhard2
Joined: 08 Dec 2015
Total Posts: 587
10 Jan 2017 07:54 AM
the data is an array. i took this from my code:
{planet1 = 0, escape1 = 0, escape2 = 0}

how would i for example wanna check if planet1 is higher than 0?
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
10 Jan 2017 07:56 AM
That's a dictionary.
You'd just say:
print(data.planet1,data.escape1,data.escape2)


Report Abuse
Festivereinhard2 is not online. Festivereinhard2
Joined: 08 Dec 2015
Total Posts: 587
10 Jan 2017 07:58 AM
so i could just do

if data.planet1 == 0 then
end
Report Abuse
Festivereinhard2 is not online. Festivereinhard2
Joined: 08 Dec 2015
Total Posts: 587
10 Jan 2017 08:00 AM
no wait i still dont get it.
would this work?

if DataStore:GetAsync(key).planet1 == 0 then
end
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
10 Jan 2017 08:02 AM
if data.planet1 > 0 then
--stuff
end

would check if planet1 in the datastore of the player is higher than 0, assuming you have declared data
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
10 Jan 2017 08:02 AM
leTable = {
["Thing1"] = 0,
["Thing2"] = 0,
["Thing3"] = 0,
}

print(leTable.Thing1)
>0


Report Abuse
Festivereinhard2 is not online. Festivereinhard2
Joined: 08 Dec 2015
Total Posts: 587
10 Jan 2017 08:04 AM
okay guys theres one more thing i dont understand. what is data? because i didnt declare that.. is data DataStore:GetAsync(key)?
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
10 Jan 2017 08:07 AM
When we used the word "data" we're just using it as an arbitrary variable so that we don't have to use :GetAsync() over and over again. You can only use :GetAsync like 60+5*game.Players.NumPlayers times per minute

data = ds:GetAsync(key)
could be any variable name
apple = ds:GetAsync(key)
pear_fruit = ds:GetAsync(key)




Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
10 Jan 2017 08:07 AM
Like soybeen showed you:

"
local key = "user_"..game.Players:GetPlayerFromCharacter(part.Parent).userId
local data = DataStore:GetAsync(key)
"
Report Abuse
Festivereinhard2 is not online. Festivereinhard2
Joined: 08 Dec 2015
Total Posts: 587
10 Jan 2017 08:11 AM
oh i get it now! thanks!
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