What do you want to achieve? Keep it simple and clear!
I want it so when players join for the first time, they teleport to a different place in the game as a tutorial place.
What is the issue? Include screenshots / videos if possible!
I cant seem to code a function to detect first time players.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Yes, but there was nothing for this topic.
And also, my teleport script:
local telePart = script.Parent
local TeleportService = game:GetService('TeleportService')
local placeID = 5020048423
local canTeleport = true
local function otherGame(otherPart)
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player and canTeleport then
canTeleport = false
TeleportService:Teleport(placeID, player)
end
end
telePart.Touched:Connect(otherGame)
You could use a Datastore for that.
You game doesnt have “Inventory” or something you are saving in a Datastore?
If you have any, just use that to know when a player is new. Check the Datastore, if the Datastore is empty related with that player, then its new, so, teleport it to the Tutorial place
Basic example:
local DSS = game:GetService("DataStoreService")
local FirstTimePlayers = DSS:GetDataStore("FirsTimePlayers")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local success, data = pcall(function()
return FirstTimePlayers:GetAsync(player.UserId)
end)
if success then
if data then
warn("player has data in datastore, means old player")
else
warn("player has no data in dss, means new player")
-- DO THE TELEPORT FUNCTION FROM HERE
end
else
warn("datastore service failed to read")
end
end)