Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make player spawn in a Place that isn't the starter place?

I have a teleporter part in my game that allows the player to move from place to place in the game. But I also want it set up so the game remembers what place they were in last and then use that as a the Place they spawn into instead of the starter place.

    local TeleportService = game:GetService("TeleportService")
    
    local Place = 2664772501
    script.Parent.Touched:Connect(function(hit)
    
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    
    if player then
    
    game.ReplicatedStorage:WaitForChild("FadeInEvent"):FireClient(player)
    
    player.Character.Humanoid.WalkSpeed = 0
    
    TeleportService:Teleport(Place, player)
   end
end)

This is how I teleport them. I already have a way of saving the place they teleported to and everything now I'm just wondering of how to set it up so that is where they spawn into when they leave the game and come back again.

I was thinking of simply using the same code when the player comes into the game (starter place) like this:

game.Players.PlayerAdded:Connect(function(player)
	local Place = <whatever I saved>
	TeleportService:Teleport(Place, player)

Is that a good way of setting it up or is there another better way that I'm not aware of?

1 answer

Use datastore to check & save the last known place in your game they visited. Using onPlayerAdded and DataStoreService this should be well possible, alright?

2 comments

0

Yes that's possible, but I wouldn't really call this an answer.

0

Yeah, I just got it to work this way. I pretty much just save the ID when they hit the teleporter and then do a check on startup to see if the place they are in matches the ID I saved and if not, teleport them to that place.

This discussion is preserved as it was. New answers, comments, and votes are closed.