script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
wait(2) – add a two-second delay
hit.Parent.HumanoidRootPart.CFrame = CFrame.new(46, 60.25, -110.669)
end
end)
How do I make it so the player has to be in the part for it to occur since I
get stuck in a teleportation loop
local Touched = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) and not touched then
touched = true
wait(2) – add a two-second delay
hit.Parent.HumanoidRootPart.CFrame = CFrame.new(46, 60.25, -110.669)
touched = false
end
end)
local part = script.Parent
local Debounce = false
part.Touched:Connect(function(hit)
local Character = hit.Parent
local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
if not Player then return end
if not Debounce then
Debounce = true
Character:PivotTo(CFrame.new(46, 60.25, -110.669))
task.wait(2)
Debounce = false
end
end)
local teleportPart = -- insert the part you want to teleport the player to
function onTouched(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
if humanoid then
local character = humanoid.Parent
if character then
local humanRootPart = character:FindFirstChild("HumanoidRootPart")
if humanRootPart then
-- check if the player is touching the teleportPart
if part == teleportPart then
-- teleport the player to the desired location
humanRootPart.CFrame = -- insert the desired location
end
end
end
end
end
teleportPart.Touched:Connect(onTouched)
it’s pretty simple, see the variable name called Touched? the others are misspelled because they don’t have an uppercase letter. Lua is case-sensitive when it comes to variables, so it won’t be able to run because it’s trying to check the value of a different value.