Hey, TeleportService is not teleporting me to the game I have asked for, all settings in relation to this are enabled. The other game is public.
Here is the code:
local teleportButton = game:WaitForChild("StarterGui"):WaitForChild("ScreenGui"):WaitForChild("Frame"):WaitForChild("TextButton")
local teleportService = game:GetService("TeleportService")
local destinationPlaceId = 6441957573 -- Replace with the actual Place ID of the destination
local destinationSpawnLocation = Vector3.new(10, 5, 0) -- Replace with the actual spawn location
function buttonHover()
teleportButton.TextColor3 = Color3.new(203, 64, 0)
end
function buttonHoverLeave()
teleportButton.TextColor3 = Color3.new(255, 77, 0)
end
function teleportPlayer()
local player = game.Players.LocalPlayer
-- Check if LocalPlayer exists
if not player then
print("LocalPlayer not found.")
return
end
-- Attempt to teleport the player
local success, errorMessage = pcall(function()
teleportService:Teleport(destinationPlaceId, player)
end)
-- Check if teleportation was successful
if not success then
print("Teleportation failed:", errorMessage)
end
end
teleportButton.MouseEnter:Connect(buttonHover)
teleportButton.MouseLeave:Connect(buttonHoverLeave)
teleportButton.MouseButton1Click:Connect(teleportPlayer)```
local teleportButton = game:WaitForChild("StarterGui"):WaitForChild("ScreenGui"):WaitForChild("Frame"):WaitForChild("TextButton")
local teleportService = game:GetService("TeleportService")
local destinationPlaceId = 6441957573 -- Replace with the actual Place ID of the destination
local destinationSpawnLocation = Vector3.new(10, 5, 0) -- Replace with the actual spawn location
function buttonHover()
teleportButton.TextColor3 = Color3.new(203, 64, 0)
end
function buttonHoverLeave()
teleportButton.TextColor3 = Color3.new(255, 77, 0)
end
function teleportPlayer()
local player = game.Players.LocalPlayer
-- Check if LocalPlayer exists
if not player then
print("LocalPlayer not found.")
return
end
-- Attempt to teleport the player
local success, errorMessage = pcall(function()
teleportService:TeleportAsync{player, destinationPlaceId}
end)
-- Check if teleportation was successful
if not success then
print("Teleportation failed:", errorMessage)
end
end
-- Button Calls
teleportButton.MouseEnter:Connect(buttonHover)
teleportButton.MouseLeave:Connect(buttonHoverLeave)
teleportButton.MouseButton1Click:Connect(teleportPlayer)```