cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
|
| 13 Apr 2016 04:06 PM |
How can I get the total amount of visitors to my game?
I'm wanting to do a reward-thingy. "Yay you're the 1000th visitor" or something |
|
|
| Report Abuse |
|
|
|
| 13 Apr 2016 04:08 PM |
| I don't think there's anything precise enough to do something like what you want, you'd probably end up giving 100 people 10000th visitor at the same time (depending on how many are joining). |
|
|
| Report Abuse |
|
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
|
| 13 Apr 2016 04:12 PM |
| I was just going to give the player(or players O.o) a little cash bonus (not real cash obviously). I was thinking about adding a value to a datastore each time a player joins, but I'm not sure how to access all the data on a datastore. |
|
|
| Report Abuse |
|
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
|
| 13 Apr 2016 04:14 PM |
...
I guess I could just make a new datastore and add one value per visit per person (unless they're a guest) and then if the datastore value==some number, then give them cash bonus |
|
|
| Report Abuse |
|
|
|
| 13 Apr 2016 04:25 PM |
Create a counter using a datastore.
local DSS=game:GetService("DataStoreService") local Counter=DSS:GetDataStore("Counter")
game.Players.PlayerAdded:connect(function(Player) if Player.Name:sub(1,6)~="Guest " then Counter:UpdateAsync(Player.userId,function(old) local new = old or 0 if new==0 then --Never visited before new = Counter:IncrementAsync("PlaceVisits",1) if new==10000 then --Do something to the 10000th player end end return new end) end end)
If your place already has place visits, start the counter at that number:
--Use this in studio or in your game once local PV = 0 --Change to number of current place visits game:GetService("DataStoreService"):GetDataStore("Counter"):SetAsync("PlaceVisits",PV)
If you want the counter to increase even if the player isn't new, just use this:
local DSS=game:GetService("DataStoreService") local Counter=DSS:GetDataStore("Counter")
game.Players.PlayerAdded:connect(function(Player) if Player.Name:sub(1,6)~="Guest " then local Number=Counter:IncrementAsync("PlaceVisits",1) if Number==10000 then --Do something to the 10000th player end end end)
There's a code in here as well for counting how many times the player visits: http://wiki.roblox.com/index.php?title=API:Class/GlobalDataStore/IncrementAsync |
|
|
| Report Abuse |
|
|