Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I fix this script that take me from one place to another?

Asked by 2 years ago
Edited 2 years ago

Hi, I wanted to know how to fix this script I made to learn how to use TeleportService. By the way, if you want to see the video I used to learn about Teleport Service, here's the link:

I also tested in the Roblox application as it doesn't work in Roblox Studio because of safety reasons. Here is the script.

Script:

local TS = game:GetService("TeleportService")
local part = script.Parent



part.Touched:Connect(function(hit)
    local human = hit.Parent:FindFirstChild("Humanoid")
    local reserveServerCode = TS:ReserveServer(7107353539)



    if human then
        local character = hit.Parent
        local player = game.Players:GetPlayerFromCharacter(character)

        local success, errormessage = pcall(function()
            TS:TeleportToPrivateServer(7107353539, reserveServerCode, player)
        end)
    end
end)

Answer this question