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?
Use datastore to check & save the last known place in your game they visited. Using onPlayerAdded and DataStoreService this should be well possible, alright?