Transfer a teleport script to the part

i have a local script that teleports, but I have to local every teleport part and every location, how would I do it in the part instead of in the local script?
the script:

local Brick = game.Workspace.Tele1 

local Debounce = false 
local Character = game.Players.LocalPlayer.Character

Brick.Touched:Connect(function(Hit)
	if Hit.Parent.Name == Character.Name and Debounce == false then 
		Debounce = true
		Character.Torso.CFrame = CFrame.new(-122.64, 0.5, -57.21) 
		wait(1)
		Debounce = false
	end
end)

As you can’t use local script in workspace, make a server script and make it a child of the part:

local Brick = script.Parent

local Debounce = false 

Brick.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(Hit.Parent)
		Debounce = true
		player.Character.Torso.CFrame = CFrame.new(-122.64, 0.5, -57.21) 
		wait(1)
		Debounce = false
	end
end)

This should work.

1 Like

Also, I recommend changing:

You should change the HumanoidRootPart’s CFrame instead of the Torso, because some players might use R15, which doesn’t have a torso in their character, instead an uppertorso, overall, it’s better to use HumanoidRootPart instead of Torso
player.Character.HumanoidRootPart.CFrame = CFrame.new(-122.64, 0.5, -57.21)

my game is r6 so i think it will be fine

When I do teleporting I like to use Character:MoveTo(Tree.Position)

I’f you want you can do something like

local Brick = script.Parent
local Part = workspace.Part

local Debounce = false 

Brick.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(Hit.Parent)
		Debounce = true
		player.Character:MoveTo(Part.Position)
		wait(1)
		Debounce = false
	end
end)
1 Like

Be careful I one used Torso.CFrame and for all other players the player’s joints were glitching everywhere.

1 Like