Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to check if its the players first time playing the game?

Asked by 5 years ago

I am not quite sure on how to do this. I want to make it into an if statement.

0
DataStores Rare_tendo 3000 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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

0
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. lunatic5 409 — 5y
0
Yeah... don't say Instance.new('BoolValue', player) as instances with their parent command is depricated and will lag your game. greatneil80 2647 — 5y
0
i removed that inefficiant insance.new, thanks lunatic & neil UnlimitedKeeping 88 — 5y
Ad
Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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"

Answer this question