I am not quite sure on how to do this. I want to make it into an if statement.
How to check if its the players first time playing the game?
2 answers
you can check that by using this script
local datastore_service = game:GetService("DataStoreService")
local firstjoin_store = datastore_service:GetDataStore("FirstJoinDatastore")
game:GetService("Players").LocalPlayer.PlayerAdded:connect(function(player)
local bool = false
bool = firstjoin_store:GetAsync(player.UserId)
if bool == false then
print("first time player joins")
firstjoin_store:SetAsync("true", player.UserId)
elseif bool == true then
print("player has joined before")
end
end
hope that script helps you, i know it might be inefficiant but it works,
edit: removed that old stinky instance.new
3 comments
The parent argument of Instance.new() is deprecated. Also, you need to do if bool.Value, not if bool. Finally, you don't need to use if bool.Value == true or if bool.Value == false, you can just use if bool and if not bool.
Yeah... don't say Instance.new('BoolValue', player) as instances with their parent command is depricated and will lag your game.
i removed that inefficiant insance.new, thanks lunatic & neil
As Doob_yyus mentioned, I suggest using DataStores, so that whenever a player enters the game, it checks if the player has the BoolValue set to true(or use numbervalues) if false then set to "True"
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
DataStores