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

I can't teleport the player between places in my game. How do I fix this?

Asked by 2 years ago

Hey! I'm working on a game but I'm having a problem.

In my game, there's multiple levels which are in different places in the same game, and I have to use a part to teleport the player to the next place. For some reason, it doesn't work. Please help!

The code is as follows:

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

local teleportPart = script.Parent
local targetPlaceID = 8493347085  -- Change this to your place ID

-- Require teleport module
local TeleportModule = require(ReplicatedStorage:WaitForChild("TeleportModule"))

local function onPartTouch(otherPart)
    -- Get player from character
    local player = Players:GetPlayerFromCharacter(otherPart.Parent)

    if player and not player:GetAttribute("Teleporting") then
        player:SetAttribute("Teleporting", true)

        -- Teleport the player
        local teleportResult = TeleportModule.teleportWithRetry(targetPlaceID, {player})

        player:SetAttribute("Teleporting", nil)
    end
end

teleportPart.Touched:Connect(onPartTouch)
0
The best way to do this would be by teleporting the HRP to the part like this (the HumanoidRootPart is in the character) ; local hrp = {humanoidrootpart_directory} hrp.Position = {your_part}.Position Korfuh 0 — 2y
0
nvm i found something else that worked. thanks for your suggestion though! PurgeThePoison 0 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

Maybe you should go to Game Settings, then Security, and then enable "Allow Third-Party Teleports". That should fix it.

Ad

Answer this question