Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does trying to index this return nil?

Asked by 10 years ago

When I try to test this Data Store script using Test Solo, the output says:

14:19:52.680 - Place has to be opened with Edit button to access DataStores 14:19:52.686 - Workspace.Script:5: attempt to index local 'PlayerStore' (a nil value) 14:19:52.688 - Script 'Workspace.Script', Line 5 14:19:52.688 - stack end

Why is it returning nil? Also I am in edit mode testing it in solo, so why does it say this?

2 answers

Log in to vote
2
Answered by
jobro13 980 Moderation Voter
10 years ago

There are some prerequisites to test Data Stores:

  1. You should test on a server
  2. You should make sure the games' PlaceId is set.

You can check the second by running the following code in the command bar:

print(game.PlaceId)

If it is 0, you have done something wrong. How to fix? Either close the page and reload your page from the "edit" button (on the roblox site, on one of your places!) OR find out the place id of one of your places (the one you are trying to edit). For example, a place id could be (in your case):

http://www.roblox.com/Bikini-Bottom-Adventure-place?id=21215459

The PlaceId in this case is 21215459

Now, to set the place id, run the following in the place where you are testing the game in Test Server:

game:SetPlaceId(21215459).

Now disable every script and re-enable them. This reloads their code and now Data Stores will work.

0
When I test server, should my character load up or no? because It isn't loading and I don't know if that's a problem or not. AwsomeSpongebob 350 — 10y
0
No, it won't load - that's how test server works! :) You basically start a server on how a server runs on roblox. You need to add a player though. Test --> Start Player. You can add as much players as you like! This makes it possible to test things like PVP too! jobro13 980 — 10y
0
Cool! AwsomeSpongebob 350 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

I would shutdown Studio then reboot it. I sometimes get this. It works for me.

Answer this question