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

How can I teleport a player to somewhere different if they are joining for the first time?

Asked by 2 years ago

So I'm making this game where you join and go to the starter menu/lobby where there are two GUI buttons that say "Play" and "Character Editor" these buttons teleport you to that part of the game. But my problem is that I want new players that are joining for the first time and click "Play", to teleport them to the character editor where they can edit their character and then join the game. Then after that, they can simply just join without having to go through that. Does anyone know how I can accomplish this? Any help is really appreciated!

TELEPORT SCRIPT:

elseif Value == "Play" then
    tpService:Teleport([GAME ID], Player)

elseif Value == "CE" then
    tpService:Teleport([GAME ID], Player)
0
Maybe you can try to either lock the other button and make "Play" the only one that's accessible or use a DataStore? NotThatFamouss 605 — 2y

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago
Edited 2 years ago

To detect if the player played for the first time, you would need "DataStore". Although your question is player playing the first time, I believe the better method is storing a data when the player customized his avatar. To check if the player customized his avatar you can set the "DataStore" to "Customized Avatar" string or just put some numbers. I will be quickly explaining how do you save and load a data.

To save a data:

local DataStoreService = game:GetService("DataStoreService")

DataStoreService:SetAsync(Key, Value)

What is a key? If you want the data to be different to everyone, the key must be unique to each other so they can have their own datas. Also I recommend you saving the player's UserId not the player name because if a guy changed his player name and it's key will be different so he paid 1000 Robux to lose his data. Since UserId is always the same for each player and it's unique so we are storing UserIds for keys.

This is the way to store a player's data to "Hi".

local DataStoreService = game:GetService("DataStoreService")

DataStoreService:SetAsync(Player.UserId, "Hi")

You saved the data, but you can't load it, so of course, to load a data:

local DataStoreService = game:GetService("DataStoreService")

DataStoreService:GetAsync(Player.UserId) -- "Hi"

Note that you don't need to put the player's value, because why do you even need the player's data if you already know??

So I think that's pretty much it, the rest are logical. But if you really want an example:

When the player clicked Play, you check his data is "Customized Avatar", if it's not, then you teleport him to the avatar customizer place. Else teleport him to the play area.

After the player customized his avatar, you set his data to "Customized Avatar" and teleport him to the play area.

To check a data is "Customized" in a if statement, I suggest you set up a variable and put the data there

That's all, you expect me to put out a paragraph to explain how do you do that in your game? I believe you can so, no, bye

Ad

Answer this question