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

why is my wiki-copied teleport script not working?

I'm making a place that's like the future of Roblox and I want to make a futuristic teleport. But it won't teleport. Here's my code: Remember, I copied it from the Wiki.

ame:GetService("TeleportService").CustomizedTeleportUI = true
local teleportService = game:GetService("TeleportService")
local otherPlaceId = 101923636 -- this is the place ID i want them to teleport to.
local button = script.Parent
local loadingScreen = script.Parent.Parent
 button.MouseButton1Click:connect(function()
	
	game:GetService("TeleportService"):Teleport(otherPlaceId)
 
	
	loadingScreen.Visible = true
 
	
	for i = 1, 0, -.05 do
		loadingScreen.BackgroundTransparency = i
		wait()
	end
	loadingScreen.BackgroundTransparency = 0
end)

game.ReplicatedStorage.TeleportRequestEvent.OnServerEvent:connect(function(player)
	
	local character = player.Character
	local forceField = Instance.new("ForceField", character)
 
	
	player.OnTeleport:connect(function(teleportState)
		if teleportState == Enum.TeleportState.Failed then -- teleport to game not working
			game.ReplicatedStorage.TeleportRequestEvent:FireClient(player)
			forceField:Destroy()
		end
	end)
	teleportService:Teleport(otherPlaceId, player) -- do I need this? I copied it from Wiki.
end)

I copied this from the Wiki so it may need some changes. Thanks for reading!

1 answer

✓ Accepted answer

I believe that you don't need some of that code. You do need to define the player when teleport. Also I suggest that you don't just copy scripts. You should look at them and try to understand what it's doing. The code is below.

The script should be in Local Script to work!

game:GetService("TeleportService").CustomizedTeleportUI = true
local teleportService = game:GetService("TeleportService")
local otherPlaceId = 101923636
local button = script.Parent
local loadingScreen = script.Parent.Parent
local player = game.Players.LocalPlayer

 button.MouseButton1Down:connect(function()
    game:GetService("TeleportService"):Teleport(otherPlaceId, player)
    loadingScreen.Visible = true
    for i = 1, 0, -.05 do
        loadingScreen.BackgroundTransparency = i
        wait()
    end
    loadingScreen.BackgroundTransparency = 0
end)

http://wiki.roblox.com/index.php?title=Teleportation

Don't forget to accept this as an answer! I made sure that the script works.

1 comment

0

thanks so much! I'm a begginer scripter and I really don't know much about teleportation and big stuff. but thanks!

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