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: Number of visits

Previous Thread :: Next Thread 
cgjnm is not online. 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
ExtremeBuilder15 is not online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
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 is not online. 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 is not online. 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
HumanXerxes is not online. HumanXerxes
Joined: 17 Apr 2011
Total Posts: 1351
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
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