|
| 21 Sep 2016 12:10 PM |
| How do you check wheather there is a key "Idea_Dolan" in the datastore? The thing I am trying to do is have an idea box, but you can only put 1 idea in there, and i want to check wheather that datastore exist or no. |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 12:19 PM |
| Simply try and read the key, if it doesn't exist the function will simply return nil. |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 12:25 PM |
Would this work
if not DataStore:GetAsync("Idea_".. script.Parent.Parent.Parent.Parent.Parent.Name) == nil then |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 12:34 PM |
| yes it returns the table stored or nil |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 21 Sep 2016 01:05 PM |
local PlayerStats = {}
local UserId = Player.UserId
local Data = PlayerData:GetAsync(UserId)
if Data then PlayerStats = Data else PlayerData:SetAsync(UserId,PlayerStats) end
|
|
|
| Report Abuse |
|
|