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)
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)
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)