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

Joining a friend in the same universe?

Asked by
RoyMer 301 Moderation Voter
8 years ago

So I've got this function off the wiki and adjusted it to my needs, but for some reason it isn't working, the place is in the same universe yet it's not working, the script.Parent.Parent.Name is the Id of the player I'd be joining.

The output statement says (although it's not global, it's in the same universe!):

HTTP 0(HTTP 403(1.1 403 Forbidden))
Line 4 - global followPlayer
Line14
Stack End

The code:

local teleportService = game:GetService'TeleportService'

function followPlayer(player, targetUserId) -- The player you are teleporting and the userId of the player you are teleporting to.
    local success, errorMsg, placeId, instanceId = teleportService:GetPlayerPlaceInstanceAsync(targetUserId)
    if success then
        teleportService:TeleportToPlaceInstance(placeId, instanceId, player)
    else
        print("Teleport error:", errorMsg)
    end
end

local player = game.Players.LocalPlayer
function Click()
    followPlayer(player, script.Parent.Parent.Name) 
end
script.Parent.MouseButton1Down:connect(Click)

Answer this question