|
| 07 Jun 2014 12:18 AM |
Does changed event work with Data Store values? Example:
Data = game:GetService("DataStoreService") Data.Changed:connect(function(Data:GetAsync("Key"))
? |
|
|
| Report Abuse |
|
|
| |
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 07 Jun 2014 12:25 AM |
You would use the OnUpdate method of GlobalDataStore
DataStore = game:GetService("DataStoreService"):GetGlobalDataStore()
DataStore:OnUpdate("key",function() --Callback function for when it is updated end) |
|
|
| Report Abuse |
|
|
|
| 07 Jun 2014 12:29 AM |
| Ohhh, because at first I was using while true do method to check if the value change but it was sort of inefficient with the small delay. So I use OnUpdate which is like the Changed event? |
|
|
| Report Abuse |
|
|
|
| 07 Jun 2014 06:02 AM |
I was just wondering, would it be the same if each player had something saved? Example:
Data = game:GetService("DataStoreService"):GetDataStore("Points") function onTouch(Player) Data:IncrementAsync(Player.name, 1) end script.Parent.Touched:connect(onTouch)
How would it look like if each player had a value? Would it be the same or different? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
DataStore
|
  |
| Joined: 07 Feb 2012 |
| Total Posts: 8540 |
|
|
| 07 Jun 2014 07:06 AM |
@Para, I don't quite get what you're asking. The only thing you'd change, if you were using OnUpdate, would be the 'key' (first argument).
Also, you shouldn't use the player's name as a key as they're able to change it.
|
|
|
| Report Abuse |
|
|
|
| 07 Jun 2014 07:12 AM |
| Oh, ok because I was counting clicks and I wanted to display the person who made the most clicks, so that was why I make a key for each player, so the key should just be then: 'Player.Name'? |
|
|
| Report Abuse |
|
|
DataStore
|
  |
| Joined: 07 Feb 2012 |
| Total Posts: 8540 |
|
|
| 07 Jun 2014 07:20 AM |
DataStore:OnUpdate(Player.Name, function(UpdatedValue) print(UpdatedValue) end)
But as I said, you shouldn't use the player's name simply because if they change their username they'll lose all their data in your game. Use their userId instead (Player.userId). |
|
|
| Report Abuse |
|
|
|
| 07 Jun 2014 07:21 AM |
| Ohhhhhh! Wow, that was so useful! Thank you so much! By the way, nice username, lol |
|
|
| Report Abuse |
|
|