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)

2 comments
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
nvm i found something else that worked. thanks for your suggestion though!