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: Can't access declared variable.

Previous Thread :: Next Thread 
TheCreationWorld is not online. TheCreationWorld
Joined: 02 Nov 2014
Total Posts: 568
22 May 2015 01:21 PM
PlayerDefault = {Lives = 5}
Players = {}
Store = game:GetService("DataStoreService"):GetDataStore("1")

game.Players.PlayerAdded:connect(function(Plr)
local UserKey = "user_"..Plr.userId
print(Store:GetAsync(UserKey))
end)

Workspace.Data:7: attempt to index global 'Store' (a nil value)
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
22 May 2015 01:58 PM
local Data = Store:GetAsync(UserKey) or 1
print(Data)

Try that.

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
22 May 2015 02:13 PM
That's not his problem though. It says "Store" is nil, which he declared at the top.
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
22 May 2015 02:14 PM
But the 7th line is the print() line.

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
22 May 2015 02:21 PM
Yes.
This has an error:
Store:GetAsync(UserKey)
because Store is nil.

Indexing means this:
Store.SomeValue
Store:AnotherValue
Store["YetAnotherValue"]

Store is a nil value, and can't be indexed.

If GetAsync was nil, it would say
"GetAsync is not a valid member of ______"
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
22 May 2015 02:22 PM
Try renaming the actual DataStore from 1 to something like "One".

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
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