Hey, I made a teleport script that teleports you to a place. And when testing it I noticed that it is really slow. (Sidenote: for those that do not know you cannot test TeleportServices in Roblox Studio) Is there any way I can fix it or atleast make it teleport the second someone touches the part?
Thanks!
-- Services to use in the code.
local teleportService = game:GetService('TeleportService')
local players = game:GetService('Players')
-- The place you are teleporting the player.
local targetPlace = ---id for the place I want to teleport
script.Parent.Touched:Connect(function(hit)
-- Most of this is from the official dev wiki.
local player = players:GetPlayerFromCharacter(hit.Parent)
-- Making sure the player exists.
if player then
-- Teleporting player
teleportService:Teleport(targetPlace, player)
end
end)
Players do not teleport instantaneously because after Teleport is called, the teleport has to be initialised. The initialisation state includes setting up the teleport according to the arguments passed in the method as well as any internal teleport processes. Initialisations can fail or succeed, the latter which then performs the actual teleport.
There is no way to make a player teleport instantly after calling the Teleport method. You’ve already done your part so the engine takes care of the rest.
As said above there is little you can do to speed up the teleport process, but you can disguise it.
Try creating a custom teleport GUI, you can animate it onto the screen as the player touches the part so the player gets immediate teleport feedback. Then in the secondary place, have a local script in replicated first to react to custom teleport UIs. Just coordinate the teleport code with a local script that sets the teleport UI and animates it on screen with a remote event or similar.