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.

01local TeleportService = game:GetService("TeleportService")
02 
03local placeID_1 = 408502340 --add the copied id here
04local placeID_2 = 408502380 --[[ i dont know what this does i got this in notepad i dont remember where i got it. ]]--
05 
06local function onPartTouch(otherPart)
07    local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
08    if player then
09        TeleportService:Teleport(placeID_1, player)
10    end
11end
12script.Parent.Touched:Connect(onPartTouch)

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

01local TeleportService = game:GetService("TeleportService")
02local Players = game:GetService("Players")
03 
04Players.PlayerAdded:Connect(function(player)
05    -- Is this player following anyone?
06    local followId = player.FollowUserId
07    -- If so, find out where they are
08    if followId and followId ~= 0 then
09        local success, errorMessage = pcall(function()
10            -- followId is the user ID of the player that you want to retrieve the place and job ID for
11            currentInstance, _, placeId, jobId = TeleportService:GetPlayerPlaceInstanceAsync(followId)
12        end)
13        if success then
14            -- Teleport player
15            TeleportService:TeleportToPlaceInstance(placeId, jobId, player)
16        end
17    else
18        warn("Player " .. player.UserId .. " is not following another player!")
19    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:

1local PlaceID = 12345
2 
3game:GetService("Players").PlayerAdded:Connect(function(User)
4    repeat wait() until User ~= nil
5    game:GetService("TeleportService"):Teleport(PlaceID, User)
6end)

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

Answer this question