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: How to know it's a player first time playing?

Previous Thread :: Next Thread 
sup3rh0tguy is not online. sup3rh0tguy
Joined: 13 May 2013
Total Posts: 54
07 Aug 2017 07:57 PM
In scripting how would I find out if this is the first time the player has ever joined my game? I want to create a GUI the player will see only the first time they join so they can select a starter weapon. Then the second time the player will not receive the GUI and will have the starter weapon in their inventory. I already know how to save the weapon using datastores but not sure about the GUI. I was thinking of when I check for the datastore I could put in an else command and then have the GUI appear but the weapon can be traded so if the player traded it away the GUI would appear again.

Something I was thinking of was to create a Boolean datastore value that changes to true when the player chooses their weapon so then after they traded it the value is still true, and new players default value would be false. I guess it would work for now but I'd have to find a new way in a later update I plan so I was just wondering if there were a way to check if it's the players first time joining through an event/function. If you know please reply, I'd appreciate the help.
Report Abuse
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
07 Aug 2017 07:58 PM
local stats = ################ if not stats then print'new player' else print 'returning player end
Report Abuse
PhantomVisual is not online. PhantomVisual
Joined: 08 Apr 2011
Total Posts: 2025
07 Aug 2017 08:05 PM
If you are storing data in your game, you could check if the player's userId is in the DataStore, if not insert the userId and give them the GUI.


Report Abuse
YoBoiDevDerpy is not online. YoBoiDevDerpy
Joined: 05 Feb 2011
Total Posts: 3020
07 Aug 2017 08:07 PM
save a boolean called hasPlayed to the player via datastores and re-save it as true once they pick their weapon (not once they join because that might result in them leaving and coming back and not being able to pick their weapon)
Report Abuse
RobuxLife is not online. RobuxLife
Joined: 19 Sep 2012
Total Posts: 13336
07 Aug 2017 09:08 PM
local dataStoreService = game:GetService("DataStoreService")
local hasPlayedDatastore = dataStoreService:GetDataStore("hasPlayedDataStore")

game.Players.PlayerAdded:connect(function(player)

local key = "player-" .. player.userId
local hasPlayed = Instance.new("BoolValue", player)
hasPlayed.Name = "hasPlayed"

local savedValues = hasPlayedDatastore:GetAsync(key)

if savedValues then
hasPlayed.Value = true
hasPlayed:Destroy()
else
hasPlayed.Value = true
hasPlayedDatastore:SetAsync(key, hasPlayed.Value)
print(key, player.Name .. " is new")
end

end)


- RL
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