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

How do i make a script that sends the player to another 'Place' in the game?

Asked by 4 years ago

I have no idea, I really need help with this. theres not really any details i can give. Oh, And when i say 'Place' i dont mean like a teleport script, i mean a script that takes you to like a place, like one of the game's places, thanks

2 answers

Log in to vote
0
Answered by 4 years ago

In game explorer, right click places. then click add new place and then name it whatever. When youre done, right click the new place and click copy id.

https://dk135eecbplh9.cloudfront.net/assets/blt57b648cb6053c4db/TeleportService-Copy-ID-to-Clipboard.png

This is the script where whenever the part is touched, you will get teleported there.

local TeleportService = game:GetService("TeleportService")

local placeID_1 = 408502340 --add the copied id here
local placeID_2 = 408502380 --[[ i dont know what this does i got this in notepad i dont remember where i got it. ]]--

local function onPartTouch(otherPart)
    local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
    if player then
        TeleportService:Teleport(placeID_1, player)
    end
end
script.Parent.Touched:Connect(onPartTouch)

and then this is the script where you can get teleported to the place where your friend is.

local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    -- Is this player following anyone?
    local followId = player.FollowUserId
    -- If so, find out where they are
    if followId and followId ~= 0 then
        local success, errorMessage = pcall(function()
            -- followId is the user ID of the player that you want to retrieve the place and job ID for
            currentInstance, _, placeId, jobId = TeleportService:GetPlayerPlaceInstanceAsync(followId)
        end)
        if success then
            -- Teleport player
            TeleportService:TeleportToPlaceInstance(placeId, jobId, player)
        end
    else
        warn("Player " .. player.UserId .. " is not following another player!")
    end
Ad
Log in to vote
0
Answered by
7zjh 146
4 years ago

I made one under a player added event. Here is the code:

local PlaceID = 12345

game:GetService("Players").PlayerAdded:Connect(function(User)
    repeat wait() until User ~= nil
    game:GetService("TeleportService"):Teleport(PlaceID, User)
end)

I'm sure that should do the trick. Send a comment informing me if it works or not.

Answer this question